@architect/inventory 4.0.7 → 4.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@architect/inventory",
3
- "version": "4.0.7",
3
+ "version": "4.0.8",
4
4
  "description": "Architect project resource enumeration utility",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -33,12 +33,12 @@ module.exports = async function getPluginModules ({ arc, inventory, errors }) {
33
33
 
34
34
  if (is.string(plugin)) {
35
35
  name = plugin
36
- pluginPath = getPath(cwd, type + 's', name)
36
+ pluginPath = await getPath(cwd, type + 's', name)
37
37
  }
38
38
  else if (is.object(plugin)) {
39
39
  name = Object.keys(plugin)[0]
40
40
  pluginPath = plugin[name].src
41
- ? resolve('.' + sep + plugin[name].src, cwd)
41
+ ? await resolve('.' + sep + plugin[name].src, cwd)
42
42
  : join(cwd, 'src', type + 's', name)
43
43
  }
44
44
 
@@ -136,17 +136,17 @@ module.exports = async function getPluginModules ({ arc, inventory, errors }) {
136
136
  return plugins
137
137
  }
138
138
 
139
- function getPath (cwd, srcDir, name) {
139
+ async function getPath (cwd, srcDir, name) {
140
140
  let path1 = join(cwd, 'src', srcDir, `${name}.js`)
141
141
  let path2 = join(cwd, 'src', srcDir, `${name}.mjs`)
142
142
  let path3 = join(cwd, 'src', srcDir, name)
143
143
  /**/ if (existsSync(path1)) return path1
144
144
  else if (existsSync(path2)) return path2
145
- else if (existsSync(path3)) return resolve(path3, cwd)
146
- return resolve(name, cwd)
145
+ else if (existsSync(path3)) return await resolve(path3, cwd)
146
+ return await resolve(name, cwd)
147
147
  }
148
148
 
149
- function resolve (path, cwd) {
149
+ async function resolve (path, cwd) {
150
150
  try {
151
151
  return require.resolve(path, { paths: [ cwd ] })
152
152
  }
@@ -155,7 +155,17 @@ function resolve (path, cwd) {
155
155
  return require.resolve(`@${path}`, { paths: [ cwd ] })
156
156
  }
157
157
  catch {
158
- return
158
+ let gotSomething
159
+ let mjsPath = `${path}/index.mjs`
160
+ try {
161
+ gotSomething = await import(mjsPath)
162
+ }
163
+ catch {
164
+ return
165
+ }
166
+ /* istanbul ignore next: idk why but for some reason nyc isn't picking up the catches; all cases are covered in tests, though! */
167
+ if (gotSomething) return mjsPath
168
+ else return
159
169
  }
160
170
  }
161
171
  }