From 82d9a850b5fbdd0472abfeab14f758e1f0d20ef3 Mon Sep 17 00:00:00 2001 From: Aditya Pandey Date: Wed, 9 Oct 2024 22:50:39 -0500 Subject: [PATCH 1/3] Handle path with whitespaces in build cmd --- packages/cli/src/commands/buildHandler.js | 12 ++++++------ packages/cli/src/lib/generatePrismaClient.js | 8 ++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/commands/buildHandler.js b/packages/cli/src/commands/buildHandler.js index 1ba64615cf1f..e6ca3b547d3e 100644 --- a/packages/cli/src/commands/buildHandler.js +++ b/packages/cli/src/commands/buildHandler.js @@ -49,7 +49,6 @@ export const handler = async ({ const { cmd, args } = generatePrismaCommand(rwjsPaths.api.dbSchema) return execa(cmd, args, { stdio: verbose ? 'inherit' : 'pipe', - shell: true, cwd: rwjsPaths.api.base, }) }, @@ -103,12 +102,14 @@ export const handler = async ({ // so that users don't have to see it when this command is called with --verbose process.env.VITE_CJS_IGNORE_WARNING = 'true' await execa( - `node ${require.resolve( - '@redwoodjs/vite/bins/rw-vite-build.mjs', - )} --webDir="${rwjsPaths.web.base}" --verbose=${verbose}`, + 'node', + [ + require.resolve('@redwoodjs/vite/bins/rw-vite-build.mjs'), + `--webDir=${path.resolve(rwjsPaths.web.base)}`, + `--verbose=${verbose}`, + ], { stdio: verbose ? 'inherit' : 'pipe', - shell: true, // `cwd` is needed for yarn to find the rw-vite-build binary // It won't change process.cwd for anything else here, in this // process @@ -148,7 +149,6 @@ export const handler = async ({ // generated Prisma Client due to require module caching await execa('yarn rw prerender', { stdio: 'inherit', - shell: true, cwd: rwjsPaths.web.base, }) } diff --git a/packages/cli/src/lib/generatePrismaClient.js b/packages/cli/src/lib/generatePrismaClient.js index 03f5cb12a820..847ff575a59e 100644 --- a/packages/cli/src/lib/generatePrismaClient.js +++ b/packages/cli/src/lib/generatePrismaClient.js @@ -22,8 +22,12 @@ export const generatePrismaCommand = (schema) => { } return { - cmd: `node "${require.resolve('prisma/build/index.js')}"`, - args: ['generate', schema && `--schema="${schema}"`], + cmd: `node`, + args: [ + require.resolve('prisma/build/index.js'), + 'generate', + schema && `--schema=${schema}`, + ], } } From a5e5c1e0c47afecbfcd8e451eb7f730b97085e30 Mon Sep 17 00:00:00 2001 From: Aditya Pandey Date: Wed, 9 Oct 2024 22:58:17 -0500 Subject: [PATCH 2/3] Add a changeset --- .changesets/11692.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changesets/11692.md diff --git a/.changesets/11692.md b/.changesets/11692.md new file mode 100644 index 000000000000..7a29d37ee1cf --- /dev/null +++ b/.changesets/11692.md @@ -0,0 +1,3 @@ +- Handle path with whitespaces in build cmd (#11692) by @callingmedic911 + +Fixes an edge case where if the path to the project has whitespaces, the build command would fail. From 01f10466fd210a9d67d8ced201ea8edf6d058a0c Mon Sep 17 00:00:00 2001 From: Aditya Pandey Date: Wed, 9 Oct 2024 23:07:40 -0500 Subject: [PATCH 3/3] Split up cmd and args for prerender command --- packages/cli/src/commands/buildHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/commands/buildHandler.js b/packages/cli/src/commands/buildHandler.js index e6ca3b547d3e..4e575b3b3cd0 100644 --- a/packages/cli/src/commands/buildHandler.js +++ b/packages/cli/src/commands/buildHandler.js @@ -147,7 +147,7 @@ export const handler = async ({ // Running a separate process here, otherwise it wouldn't pick up the // generated Prisma Client due to require module caching - await execa('yarn rw prerender', { + await execa('yarn', ['rw', 'prerender'], { stdio: 'inherit', cwd: rwjsPaths.web.base, })