aneka 0.0.12 → 0.0.13
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 +1 -1
- package/src/loader/require-base.js +18 -0
- package/src/misc/fatal.js +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const { isFunction } = require('lodash')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const pathResolve = require('../fs/path-resolve')
|
|
4
|
+
|
|
5
|
+
module.exports = function (file, options) {
|
|
6
|
+
const parsed = path.parse(pathResolve(file))
|
|
7
|
+
try {
|
|
8
|
+
const mod = require(parsed.dir + '/' + parsed.name + '.js')
|
|
9
|
+
if (isFunction(mod)) return mod(options)
|
|
10
|
+
return mod
|
|
11
|
+
} catch (err) {
|
|
12
|
+
try {
|
|
13
|
+
return require(parsed.dir + '/' + parsed.name + '.json')
|
|
14
|
+
} catch (err) {
|
|
15
|
+
throw err
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|