Skip to content

Commit 237a221

Browse files
authored
fix: address DEP0190 by removing shell: true and using cmd.exe on Windows (#14)
1 parent 95a064c commit 237a221

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/workspace-dev.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,18 @@ export class WorkspaceDevRunner {
189189
}
190190
this.visiting[node] = true;
191191

192-
const child = spawn('npm', ['run', command], {
192+
const spawnCommand = process.platform === 'win32' ? 'cmd.exe' : 'npm';
193+
const spawnArgs =
194+
process.platform === 'win32'
195+
? ['/c', 'npm', 'run', command]
196+
: ['run', command];
197+
198+
const child = spawn(spawnCommand, spawnArgs, {
193199
cwd: path,
194200
env: {
195201
...process.env,
196202
FORCE_COLOR: '3',
197203
},
198-
shell: true,
199204
});
200205

201206
child.stdout.on('data', async (data) => {

test/index.pw.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ test('should run dev succeed', async ({ page }) => {
1414
let testCompleted = false;
1515
let serverStarted = false;
1616

17-
const child = spawn('pnpm', ['run', 'dev'], {
17+
const command = process.platform === 'win32' ? 'cmd.exe' : 'pnpm';
18+
const args =
19+
process.platform === 'win32'
20+
? ['/c', 'pnpm', 'run', 'dev']
21+
: ['run', 'dev'];
22+
23+
const child = spawn(command, args, {
1824
cwd,
19-
shell: true,
2025
});
2126

2227
child.stdout.on('data', async (data) => {

0 commit comments

Comments
 (0)