@openinc/parse-server-opendash 4.4.2 → 4.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/functions/_init.js +14 -1
- package/dist/hooks/_init.js +13 -1
- package/package.json +1 -1
package/dist/functions/_init.js
CHANGED
|
@@ -13,7 +13,20 @@ async function init() {
|
|
|
13
13
|
.map((filename) => filename.replace(".js", ""))
|
|
14
14
|
.filter((name) => regex.test(name));
|
|
15
15
|
for (const name of fns) {
|
|
16
|
+
// One unusable module must not cost the whole boot. `init` missing is the
|
|
17
|
+
// realistic case — a file whose content is commented out still compiles to
|
|
18
|
+
// a module, and the resulting `init is not a function` used to abort
|
|
19
|
+
// `initFunctions()` and everything the entrypoint runs after it.
|
|
16
20
|
const { init } = require(`./${name}`);
|
|
17
|
-
|
|
21
|
+
if (typeof init !== "function") {
|
|
22
|
+
console.error(`[@openinc/parse-server-opendash] Cloud function "${name}" exports no init() — skipped`);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
await init(name);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error(`[@openinc/parse-server-opendash] Cloud function "${name}" failed to initialize:`, error);
|
|
30
|
+
}
|
|
18
31
|
}
|
|
19
32
|
}
|
package/dist/hooks/_init.js
CHANGED
|
@@ -18,7 +18,19 @@ async function init() {
|
|
|
18
18
|
.map((filename) => filename.replace(".js", "")),
|
|
19
19
|
];
|
|
20
20
|
for (const name of classNames) {
|
|
21
|
+
// A class whose module exports no `init` is skipped rather than allowed to
|
|
22
|
+
// throw: the hooks of every class after it — and every init step after
|
|
23
|
+
// `initHooks()` — would otherwise never be registered.
|
|
21
24
|
const { init } = require(`./${name}`);
|
|
22
|
-
|
|
25
|
+
if (typeof init !== "function") {
|
|
26
|
+
console.error(`[@openinc/parse-server-opendash] Hook module "${name}" exports no init() — skipped`);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
await init();
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error(`[@openinc/parse-server-opendash] Hooks for "${name}" failed to initialize:`, error);
|
|
34
|
+
}
|
|
23
35
|
}
|
|
24
36
|
}
|