trm-core 9.10.0 → 9.10.1
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/changelog.txt +4 -0
- package/dist/commons/getNodePackage.js +18 -7
- package/package.json +1 -1
package/changelog.txt
CHANGED
|
@@ -5,6 +5,17 @@ const node_fs_1 = require("node:fs");
|
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const trm_commons_1 = require("trm-commons");
|
|
7
7
|
function getNodePackage(globalPath, packageName) {
|
|
8
|
+
if (process.env.TRM_PREFER_BUNDLED_PACKAGES === '1') {
|
|
9
|
+
const parts = __dirname.split(node_path_1.sep);
|
|
10
|
+
const index = parts.lastIndexOf('node_modules');
|
|
11
|
+
const requestedPackage = packageName || 'trm-core';
|
|
12
|
+
if (index !== -1) {
|
|
13
|
+
try {
|
|
14
|
+
return JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(parts.slice(0, index + 1).join(node_path_1.sep), requestedPackage, 'package.json'), 'utf8'));
|
|
15
|
+
}
|
|
16
|
+
catch (_a) { }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
8
19
|
if (!globalPath) {
|
|
9
20
|
globalPath = (0, trm_commons_1.getGlobalNodeModules)();
|
|
10
21
|
}
|
|
@@ -15,20 +26,20 @@ function getNodePackage(globalPath, packageName) {
|
|
|
15
26
|
try {
|
|
16
27
|
return JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(parts.slice(0, index + 1).join(node_path_1.sep), packageName, 'package.json'), 'utf8'));
|
|
17
28
|
}
|
|
18
|
-
catch (
|
|
29
|
+
catch (_b) { }
|
|
19
30
|
try {
|
|
20
31
|
const data = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)((0, node_path_1.resolve)(parts.slice(0, index + 1).join(node_path_1.sep), '..'), 'package.json'), 'utf8'));
|
|
21
32
|
if (data.name === packageName) {
|
|
22
33
|
return data;
|
|
23
34
|
}
|
|
24
35
|
}
|
|
25
|
-
catch (
|
|
36
|
+
catch (_c) { }
|
|
26
37
|
}
|
|
27
38
|
else {
|
|
28
39
|
try {
|
|
29
40
|
return JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(parts.slice(0, index + 1).join(node_path_1.sep), 'trm-core', 'package.json'), 'utf8'));
|
|
30
41
|
}
|
|
31
|
-
catch (
|
|
42
|
+
catch (_d) { }
|
|
32
43
|
}
|
|
33
44
|
}
|
|
34
45
|
else {
|
|
@@ -41,19 +52,19 @@ function getNodePackage(globalPath, packageName) {
|
|
|
41
52
|
return data;
|
|
42
53
|
}
|
|
43
54
|
}
|
|
44
|
-
catch (
|
|
55
|
+
catch (_e) { }
|
|
45
56
|
try {
|
|
46
57
|
return JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(process.cwd(), 'node_modules', packageName, 'package.json'), 'utf8'));
|
|
47
58
|
}
|
|
48
|
-
catch (
|
|
59
|
+
catch (_f) { }
|
|
49
60
|
try {
|
|
50
61
|
return JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)((0, node_path_1.resolve)(process.cwd(), ".."), packageName, 'package.json'), 'utf8'));
|
|
51
62
|
}
|
|
52
|
-
catch (
|
|
63
|
+
catch (_g) { }
|
|
53
64
|
try {
|
|
54
65
|
return JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)((0, node_path_1.resolve)(process.cwd(), ".."), 'node_modules', packageName, 'package.json'), 'utf8'));
|
|
55
66
|
}
|
|
56
|
-
catch (
|
|
67
|
+
catch (_h) { }
|
|
57
68
|
}
|
|
58
69
|
throw new Error(`Couldn't find "${packageName}" package.json!`);
|
|
59
70
|
}
|