Skip to content

Commit

Permalink
fix(cli): better compatibility when installing dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexcited committed Jul 21, 2024
1 parent c30e58d commit e0b3453
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions .changeset/tender-islands-cheat.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@

- Add NPM provenance to all packages.
- Use real version on CLI.
- Use `shell: true` on CLI for installing dependencies : works better on Windows.
18 changes: 13 additions & 5 deletions packages/cli/src/utils/installDependencies.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { spawnSync } from "node:child_process";
import { spawn } from "node:child_process";
import { detectPackageManager } from "nypm";

export const installDependencies = async (projectDirectory: string): Promise<void> => {
const packageManager = await detectPackageManager(projectDirectory)
const command = packageManager?.command ?? "npm";
let command = packageManager?.command ?? "npm";

return new Promise((resolve, reject) => {
const child = spawn(command, ['install'], {
cwd: projectDirectory,
stdio: "ignore",
shell: true
});

spawnSync(command, ['install'], {
cwd: projectDirectory,
stdio: 'ignore'
child.on('exit', (code) => {
if (code === 0) resolve();
else reject();
});
});
}

0 comments on commit e0b3453

Please sign in to comment.