@leonid-shutov/uncommonjs 1.0.0-alpha.2 → 1.0.0-alpha.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.
@@ -9,10 +9,11 @@ const { loadDir, loadFile } = require('./loader.js');
9
9
 
10
10
  const getDefaultApplicationPath = () => path.join(process.cwd(), 'application');
11
11
 
12
- const readLayers = (applicationPath) =>
12
+ const readLayers = async (applicationPath) =>
13
13
  fsp
14
14
  .readFile(path.join(applicationPath, '.layers'), 'utf8')
15
- .then((data) => data.split(/[\r\n\s]+/).filter((s) => s.length !== 0));
15
+ .then((data) => data.split(/[\r\n\s]+/).filter((s) => s.length !== 0))
16
+ .catch(() => fsp.readdir(applicationPath));
16
17
 
17
18
  const loader = (context) => (layer) => {
18
19
  if (layer.endsWith('.js')) return loadFile(context, context, layer);
package/lib/loader.js CHANGED
@@ -26,7 +26,7 @@ const loadFile = async (context, container, filePath, key) => {
26
26
  };
27
27
 
28
28
  const loadDir = async (context, container, dirPath, key) => {
29
- key ??= dirPath.split('/').at(-1);
29
+ key ??= removeIndex(dirPath.split('/').at(-1));
30
30
  const nextContainer = container[key] ?? {};
31
31
  container[key] = nextContainer;
32
32
  const files = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leonid-shutov/uncommonjs",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.4",
4
4
  "author": "Leonid Shutov <leonid.shutov.main@gmail.com>",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/leonid-shutov/uncommonjs#readme",