chocola 1.1.4 → 1.1.5

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.
@@ -13,37 +13,43 @@ import path from "path";
13
13
  * }}
14
14
  */
15
15
  export async function getComponents(libDir) {
16
- let componentsLib = [];
17
- let loadedComponents = new Map();
18
- let notDefComps = [];
16
+ try {
17
+ let componentsLib = [];
18
+ let loadedComponents = new Map();
19
+ let notDefComps = [];
19
20
 
20
- const components = await fs.readdir(libDir);
21
+ const components = await fs.readdir(libDir);
21
22
 
22
- for (const comp of components) {
23
- if (!comp.endsWith(".js") || comp[0] !== comp[0].toUpperCase()) continue;
23
+ if (!components) throw Error(`The specified components folder ${libDir} could not be found.`)
24
24
 
25
- componentsLib.push(comp);
25
+ for (const comp of components) {
26
+ if (!comp.endsWith(".js") || comp[0] !== comp[0].toUpperCase()) continue;
26
27
 
27
- const module = await loadWithAssets(path.join(libDir, comp));
28
+ componentsLib.push(comp);
28
29
 
29
- if (typeof module.default !== "function") {
30
- notDefComps.push(comp);
31
- continue;
32
- }
30
+ const module = await loadWithAssets(path.join(libDir, comp));
31
+
32
+ if (typeof module.default !== "function") {
33
+ notDefComps.push(comp);
34
+ continue;
35
+ }
36
+
37
+ const instance = module.default();
33
38
 
34
- const instance = module.default();
39
+ if (instance.bodyPath) {
40
+ instance.body = await fs.readFile(
41
+ path.resolve(libDir, instance.bodyPath),
42
+ "utf8"
43
+ );
44
+ }
35
45
 
36
- if (instance.bodyPath) {
37
- instance.body = await fs.readFile(
38
- path.resolve(libDir, instance.bodyPath),
39
- "utf8"
40
- );
46
+ loadedComponents.set(comp.toLowerCase(), instance);
41
47
  }
42
48
 
43
- loadedComponents.set(comp.toLowerCase(), instance);
49
+ return { componentsLib, loadedComponents, notDefComps };
50
+ } catch (err) {
51
+ throwError(err)
44
52
  }
45
-
46
- return { componentsLib, loadedComponents, notDefComps };
47
53
  }
48
54
 
49
55
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chocola",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Chocola pipeline for web apps.",
5
5
  "keywords": [
6
6
  "web",