Skip to content

Commit 66f9cad

Browse files
fix: npm list
1 parent 3ad67bb commit 66f9cad

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/services/cli.services.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,24 @@ const detectCliAlreadyInstalled = async (): Promise<boolean> => {
1212
return false;
1313
}
1414

15-
const args =
16-
pm === 'yarn' ? ['global', 'list', '--depth=0'] : ['list', '--depth', '0', '--global'];
15+
try {
16+
const args =
17+
pm === 'yarn' ? ['global', 'list', '--depth=0'] : ['list', '--depth', '0', '--global'];
1718

18-
let stdout = '';
19+
let stdout = '';
1920

20-
await spawn({
21-
command: pm,
22-
args,
23-
stdout: (output: string) => (stdout += output),
24-
silentOut: true
25-
});
21+
await spawn({
22+
command: pm,
23+
args,
24+
stdout: (output: string) => (stdout += output),
25+
silentOut: true
26+
});
2627

27-
return stdout.includes(CLI_PACKAGE);
28+
return stdout.includes(CLI_PACKAGE);
29+
} catch (_err: unknown) {
30+
// According to our tests, on Windows, npm might just throw an error if there are no global lib installed yet. Therefore, we consider here an error as the CLI not being installed yet.
31+
return false;
32+
}
2833
};
2934

3035
const install = async () => {

0 commit comments

Comments
 (0)