-
Notifications
You must be signed in to change notification settings - Fork 116
/
resolver-extended.js
41 lines (38 loc) · 1.16 KB
/
resolver-extended.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { join, parse } = require("path");
const nsWebpack = require("nativescript-dev-webpack");
const fs = require("fs");
module.exports.getResolverExtended = function (platforms, project) {
let path = nsWebpack.getResolver(platforms);
return function (path) {
const {
dir,
name,
ext
} = parse(path);
let newDir = dir;
for (const platform of platforms) {
if (dir.endsWith('environments') && dir.search('node_modules') < 0 ) {
newDir = toSystemPath(join(dir, project));
}
const platformFileName = `${name}.${platform}${ext}`;
const platformPath = toSystemPath(join(newDir, platformFileName));
try {
if (fs.statSync(platformPath)) {
return platformPath;
}
} catch (_e) {
// continue checking the other platforms
}
}
return path;
}
}
// Convert paths from \c\some\path to c:\some\path
function toSystemPath(path) {
if (!process.platform.startsWith("win32")) {
return path;
}
const drive = path.match(/^\\(\w)\\(.*)$/);
return path;
}
//# sourceMappingURL=resolver.js.map