@neovici/cfg 1.12.1 → 1.12.2
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/eslint/node-enhanced.js +21 -55
- package/package.json +1 -1
package/eslint/node-enhanced.js
CHANGED
|
@@ -1,60 +1,26 @@
|
|
|
1
|
-
/* eslint-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/* eslint-env node */
|
|
2
|
+
/* eslint-disable import/group-exports */
|
|
3
|
+
const { create } = require('enhanced-resolve'),
|
|
4
|
+
path = require('path'),
|
|
5
|
+
isCore = require('is-core-module');
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
let resolver;
|
|
7
8
|
|
|
8
|
-
exports.
|
|
9
|
-
let resolvedPath;
|
|
9
|
+
exports.interfaceVersion = 2;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
exports.resolve = (source, file, config = {}) => {
|
|
12
|
+
resolver = resolver || create.sync(config);
|
|
13
|
+
if (isCore(source)) {
|
|
14
|
+
return { found: true, path: null };
|
|
15
|
+
}
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
try {
|
|
18
|
+
const resolved = resolver({}, path.dirname(file), source);
|
|
19
|
+
return {
|
|
20
|
+
found: true,
|
|
21
|
+
path: resolved,
|
|
22
|
+
};
|
|
23
|
+
} catch (err) {
|
|
24
|
+
return { found: false };
|
|
25
|
+
}
|
|
22
26
|
};
|
|
23
|
-
|
|
24
|
-
function opts(file, config, packageFilter) {
|
|
25
|
-
return Object.assign({
|
|
26
|
-
// more closely matches Node (#333)
|
|
27
|
-
// plus 'mjs' for native modules! (#939)
|
|
28
|
-
extensions: ['.mjs', '.js', '.json', '.node'],
|
|
29
|
-
},
|
|
30
|
-
config,
|
|
31
|
-
{
|
|
32
|
-
// path.resolve will handle paths relative to CWD
|
|
33
|
-
basedir: path.dirname(path.resolve(file)),
|
|
34
|
-
packageFilter,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function identity(x) { return x; }
|
|
39
|
-
|
|
40
|
-
function packageFilter(pkg, dir, config) {
|
|
41
|
-
let found = false;
|
|
42
|
-
const file = path.join(dir, 'dummy.js');
|
|
43
|
-
if (pkg.module) {
|
|
44
|
-
try {
|
|
45
|
-
resolve.sync(String(pkg.module).replace(/^(?:\.\/)?/, './'), opts(file, config, identity));
|
|
46
|
-
pkg.main = pkg.module;
|
|
47
|
-
found = true;
|
|
48
|
-
} catch (err) {
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (!found && pkg['jsnext:main']) {
|
|
52
|
-
try {
|
|
53
|
-
resolve.sync(String(pkg['jsnext:main']).replace(/^(?:\.\/)?/, './'), opts(file, config, identity));
|
|
54
|
-
pkg.main = pkg['jsnext:main'];
|
|
55
|
-
found = true;
|
|
56
|
-
} catch (err) {
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return pkg;
|
|
60
|
-
}
|