Skip to content

Commit 5863bf2

Browse files
committed
fix windows
1 parent ffc42f3 commit 5863bf2

File tree

1 file changed

+10
-35
lines changed

1 file changed

+10
-35
lines changed

epicshop/setup-custom.js

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { spawn } from 'node:child_process'
21
import path from 'node:path'
32
import { warm } from '@epic-web/workshop-cli/warm'
43
import {
54
getApps,
65
isProblemApp,
76
setPlayground,
87
} from '@epic-web/workshop-utils/apps.server'
8+
import { execa } from 'execa'
99
import fsExtra from 'fs-extra'
1010

1111
await warm()
@@ -14,41 +14,16 @@ const allApps = await getApps()
1414

1515
console.log('🔗 Generating React Router types')
1616
for (const app of allApps) {
17-
// run npx react-router typegen in app
18-
await runWithOutputOnFailure('npx', ['react-router', 'typegen'], {
19-
cwd: app.fullPath,
20-
})
21-
}
22-
23-
function runWithOutputOnFailure(command, args, options) {
24-
// { type: 'stdout', data: Buffer }
25-
const outputBuffer = []
26-
return new Promise((resolve, reject) => {
27-
const child = spawn(command, args, {
28-
...options,
29-
stdio: ['ignore', 'pipe', 'pipe'],
30-
})
31-
child.stdout.on('data', (data) => {
32-
outputBuffer.push({ type: 'stdout', data })
17+
try {
18+
await execa('react-router', ['typegen'], {
19+
cwd: app.fullPath,
20+
stdio: 'pipe',
3321
})
34-
child.stderr.on('data', (data) => {
35-
outputBuffer.push({ type: 'stderr', data })
36-
})
37-
child.on('close', (code) => {
38-
if (code !== 0) {
39-
for (const { type, data } of outputBuffer) {
40-
if (type === 'stderr') {
41-
process.stderr.write(data)
42-
} else {
43-
process.stdout.write(data)
44-
}
45-
}
46-
reject(code)
47-
} else {
48-
resolve('ok')
49-
}
50-
})
51-
})
22+
} catch (error) {
23+
if (error.stdout) process.stdout.write(error.stdout)
24+
if (error.stderr) process.stderr.write(error.stderr)
25+
throw error
26+
}
5227
}
5328

5429
const problemApps = allApps.filter(isProblemApp)

0 commit comments

Comments
 (0)