Skip to content

Commit

Permalink
fix(crwrsca): Spawn in shell on Windows (#11565)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored and Josh-Walker-GM committed Sep 16, 2024
1 parent f5e6efb commit 1fbb18f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
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

0 comments on commit 1fbb18f

Please sign in to comment.