Skip to content

Commit 806b545

Browse files
committed
support playground run on windows
1 parent f396fe2 commit 806b545

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

playground/api/router.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import Router from '@koa/router'
22
import path from 'path'
33
import fs from 'fs-extra'
4+
import os from 'os'
45
import { ROOT_DIR } from './constants'
56
import { spawnSync } from 'child_process'
67
import { getMeta } from './controllers'
78

89
const router = new Router()
10+
const cmdSuffix = os.platform() === 'win32' ? '.cmd' : ''
911

1012
router.get('/', (ctx) => {
1113
ctx.body = 'Hello'
@@ -36,7 +38,7 @@ router.post('/run/:trans', async (ctx) => {
3638
const input = ctx.request.body
3739
const script = path.resolve(__dirname, 'transfrom.ts')
3840

39-
const result = spawnSync('ts-node', ['-T', script, name], {
41+
const result = spawnSync(`ts-node${cmdSuffix}`, ['-T', script, name], {
4042
input,
4143
encoding: 'utf-8',
4244
})

0 commit comments

Comments
 (0)