@promise-watch/core
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -33,10 +33,19 @@ "use strict"; | ||
const imports = await Promise.all(files.map(f => Promise.resolve().then(() => __importStar(require((0, path_1.resolve)(dir, "../", f)))))); | ||
return imports.map((r, idx) => { | ||
return imports.map(({ name, run, options }, idx) => { | ||
name = name !== null && name !== void 0 ? name : files[idx].replace("runs/", ""); | ||
return { name, run, options }; | ||
}).reduce((prev, next) => { | ||
var _a; | ||
return ({ | ||
name: (_a = r.name) !== null && _a !== void 0 ? _a : files[idx].replace("runs/", ""), | ||
run: r.run, | ||
options: r.options, | ||
}); | ||
}); | ||
const errors = []; | ||
if (typeof next.run !== "function") | ||
errors.push(`* missing required export async function run()`); | ||
if (typeof ((_a = next.options) === null || _a === void 0 ? void 0 : _a.interval) !== "number") | ||
errors.push(`* missing required export const option.interval`); | ||
if (errors.length) { | ||
console.log(`${next.name} has errors and was skipped:`); | ||
console.log(errors.join("\n"), "\n"); | ||
return [...prev]; | ||
} | ||
return [...prev, next]; | ||
}, []); | ||
} | ||
@@ -43,0 +52,0 @@ async function sendNotifications({ title, body, notifiers, isSuccess = false }) { |
{ | ||
"name": "@promise-watch/core", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"main": "dist/index.js", | ||
@@ -18,3 +18,3 @@ "author": "Jason Raimondi <jason@raimondi.us> (https://jasonraimondi.com)", | ||
"@types/glob": "^7.2.0", | ||
"playwright": "^1.19.1", | ||
"playwright": "^1.19.2", | ||
"prettier": "^2.5.1" | ||
@@ -21,0 +21,0 @@ }, |
@@ -32,7 +32,19 @@ import { resolve } from "path"; | ||
const imports = await Promise.all(files.map(f => import(resolve(dir, "../", f)))); | ||
return imports.map((r: RunPage, idx) => ({ | ||
name: r.name ?? files[idx].replace("runs/", ""), | ||
run: r.run, | ||
options: r.options, | ||
})); | ||
return imports.map(({ name, run, options }: RunPage, idx) => { | ||
name = name ?? files[idx].replace("runs/", "") | ||
return { name, run, options } | ||
}).reduce((prev, next) => { | ||
const errors = []; | ||
if (typeof next.run !== "function") errors.push(`* missing required export async function run()`); | ||
if (typeof next.options?.interval !== "number") errors.push(`* missing required export const option.interval`); | ||
if (errors.length) { | ||
console.log(`${next.name} has errors and was skipped:`); | ||
console.log(errors.join("\n"), "\n"); | ||
return [...prev]; | ||
} | ||
return [...prev, next]; | ||
}, [] as Required<RunPage>[]) | ||
} | ||
@@ -68,2 +80,3 @@ | ||
} catch (err: any) { | ||
// if we have already notified about the error, | ||
@@ -70,0 +83,0 @@ // wait until success before sending another notification |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16996
318