Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(crwrsca): Spawn in shell on Windows #11565

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/create-redwood-rsc-app/src/install.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { spawnSync } from 'node:child_process'
import fs from 'node:fs'
import path from 'node:path'
import process from 'node:process'

import type { Config } from './config.js'

Expand All @@ -13,5 +14,10 @@ export function install(config: Config) {
// this project)
fs.writeFileSync(path.join(config.installationDir, 'yarn.lock'), '')

spawnSync('yarn', ['install'], { cwd: config.installationDir })
spawnSync('yarn', ['install'], {
cwd: config.installationDir,
// On Windows `yarn` isn't an executable. It can't be run as a system
// process. So it needs to be run in a shell process.
shell: process.platform === 'win32',
})
}
10 changes: 8 additions & 2 deletions packages/create-redwood-rsc-app/src/latest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { SpawnSyncOptions } from 'node:child_process'

import { spawnSync } from 'node:child_process'
import fs from 'node:fs'
import process from 'node:process'

import type { Config } from './config.js'

Expand Down Expand Up @@ -86,13 +89,16 @@ export function relaunchOnLatest(config: Config) {
}
}

const spawnOpts = {
const spawnOpts: SpawnSyncOptions = {
stdio: 'inherit',
// On Windows, `npx` isn't an executable, so we need to run it in a shell
shell: process.platform === 'win32',
env: {
...process.env,
// Install without asking for confirmation
npm_config_yes: 'true',
},
} as const
}

let result: ReturnType<typeof spawnSync>

Expand Down
Loading