node-modules-tools 0.0.2 → 0.0.4
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/dist/chunks/pnpm.mjs +20 -4
- package/package.json +1 -1
package/dist/chunks/pnpm.mjs
CHANGED
|
@@ -2,12 +2,28 @@ import { relative, dirname } from 'pathe';
|
|
|
2
2
|
import { x } from 'tinyexec';
|
|
3
3
|
|
|
4
4
|
async function resolveRoot(options) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
let raw;
|
|
6
|
+
try {
|
|
7
|
+
raw = (await x("pnpm", ["root", "-w"], { throwOnError: true, nodeOptions: { cwd: options.cwd } })).stdout.trim();
|
|
8
|
+
} catch {
|
|
9
|
+
try {
|
|
10
|
+
raw = (await x("pnpm", ["root"], { throwOnError: true, nodeOptions: { cwd: options.cwd } })).stdout.trim();
|
|
11
|
+
} catch (err) {
|
|
12
|
+
console.error("Failed to resolve root directory");
|
|
13
|
+
console.error(err);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return raw ? dirname(raw) : options.cwd;
|
|
7
17
|
}
|
|
8
18
|
async function getPnpmVersion(options) {
|
|
9
|
-
|
|
10
|
-
|
|
19
|
+
try {
|
|
20
|
+
const raw = await x("pnpm", ["--version"], { throwOnError: true, nodeOptions: { cwd: options.cwd } });
|
|
21
|
+
return raw.stdout.trim();
|
|
22
|
+
} catch (err) {
|
|
23
|
+
console.error("Failed to get pnpm version");
|
|
24
|
+
console.error(err);
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
11
27
|
}
|
|
12
28
|
async function getDependenciesTree(options) {
|
|
13
29
|
const args = ["ls", "--json", "--no-optional", "--depth", String(options.depth)];
|