mirror of
https://github.com/chenasraf/DefinitelyTyped-tools.git
synced 2026-05-18 01:49:03 +00:00
Format
This commit is contained in:
@@ -42,24 +42,27 @@ export default function main() {
|
||||
});
|
||||
}
|
||||
|
||||
type LockFileResult = { triggered: true } | { triggered: false, timestamp: string };
|
||||
type LockFileResult = { triggered: true } | { triggered: false; timestamp: string };
|
||||
|
||||
async function withFileLock(lockFilePath: string, cb: () => Promise<void>): Promise<LockFileResult> {
|
||||
if (await pathExists(lockFilePath)) {
|
||||
return { triggered: false, timestamp: await readFile(lockFilePath, "utf8")};
|
||||
return { triggered: false, timestamp: await readFile(lockFilePath, "utf8") };
|
||||
} else {
|
||||
await writeFile(lockFilePath, currentTimeStamp());
|
||||
cb().then(() => remove(lockFilePath), async error => {
|
||||
await removeLock();
|
||||
applicationinsights.defaultClient.trackEvent({
|
||||
name: "crash",
|
||||
properties: {
|
||||
error: String(error)
|
||||
}
|
||||
});
|
||||
cb().then(
|
||||
() => remove(lockFilePath),
|
||||
async error => {
|
||||
await removeLock();
|
||||
applicationinsights.defaultClient.trackEvent({
|
||||
name: "crash",
|
||||
properties: {
|
||||
error: String(error)
|
||||
}
|
||||
});
|
||||
|
||||
process.exit(1);
|
||||
});
|
||||
process.exit(1);
|
||||
}
|
||||
);
|
||||
|
||||
return { triggered: true };
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { AzureFunction, Context } from "@azure/functions";
|
||||
import main from "../main";
|
||||
|
||||
const httpTrigger: AzureFunction = async function (context: Context): Promise<void> {
|
||||
context.log('HTTP trigger function processed a request.');
|
||||
const httpTrigger: AzureFunction = async function(context: Context): Promise<void> {
|
||||
context.log("HTTP trigger function processed a request.");
|
||||
const res = await main();
|
||||
context.log(res);
|
||||
context.res = res;
|
||||
|
||||
Reference in New Issue
Block a user