From a5e0e14e6973903f3f690a9953a4b654760aaf42 Mon Sep 17 00:00:00 2001 From: Addison <42930383+addisonschultz@users.noreply.github.com> Date: Tue, 21 Nov 2023 14:51:55 +0100 Subject: [PATCH] Fix bug where CLI fails when installing dependencies on Windows machines (#304) * Add test for windows when installing deps * Add changeset --- .changeset/sweet-seahorses-complain.md | 5 +++++ packages/cli/src/init.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/sweet-seahorses-complain.md diff --git a/.changeset/sweet-seahorses-complain.md b/.changeset/sweet-seahorses-complain.md new file mode 100644 index 000000000..d8fc4a035 --- /dev/null +++ b/.changeset/sweet-seahorses-complain.md @@ -0,0 +1,5 @@ +--- +'@gitbook/cli': minor +--- + +Updates the CLI to check for Windows machines in order to install dependencies correctly diff --git a/packages/cli/src/init.ts b/packages/cli/src/init.ts index de9d128fd..2d40dbb2e 100644 --- a/packages/cli/src/init.ts +++ b/packages/cli/src/init.ts @@ -171,7 +171,7 @@ export async function extendPackageJson(dirPath: string, projectName: string): P */ export function installDependencies(dirPath: string): Promise { return new Promise((resolve, reject) => { - const install = spawn('npm', ['install'], { + const install = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['install'], { stdio: 'inherit', cwd: dirPath, });