From 1dc208356abdcf8d3c0e826fd2184624298dd771 Mon Sep 17 00:00:00 2001
From: Sohum <31165513+ssmendon@users.noreply.github.com>
Date: Sun, 13 Oct 2024 17:46:51 +0000
Subject: [PATCH] fix(cli): use shell on win32 for `update` (#1503) (#1504)
---
quartz/cli/handlers.js | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/quartz/cli/handlers.js b/quartz/cli/handlers.js
index 12e7e8e..ed1c0e2 100644
--- a/quartz/cli/handlers.js
+++ b/quartz/cli/handlers.js
@@ -457,7 +457,25 @@
await popContentFolder(contentFolder)
console.log("Ensuring dependencies are up to date")
- const res = spawnSync("npm", ["i"], { stdio: "inherit" })
+
+ /*
+ On Windows, if the command `npm` is really `npm.cmd', this call fails
+ as it will be unable to find `npm`. This is often the case on systems
+ where `npm` is installed via a package manager.
+
+ This means `npx quartz update` will not actually update dependencies
+ on Windows, without a manual `npm i` from the caller.
+
+ However, by spawning a shell, we are able to call `npm.cmd`.
+ See: https://nodejs.org/api/child_process.html#spawning-bat-and-cmd-files-on-windows
+ */
+
+ const opts = { stdio: "inherit" }
+ if (process.platform === "win32") {
+ opts.shell = true
+ }
+
+ const res = spawnSync("npm", ["i"], opts)
if (res.status === 0) {
console.log(chalk.green("Done!"))
} else {
--
Gitblit v1.10.0