From 48f700bcf766b60ead00b1821086d79e877465ab Mon Sep 17 00:00:00 2001 From: ygj6 Date: Fri, 28 May 2021 12:07:35 +0800 Subject: [PATCH 1/3] support playground run on windows --- playground/api/router.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/playground/api/router.ts b/playground/api/router.ts index 0adb88f..8118c16 100644 --- a/playground/api/router.ts +++ b/playground/api/router.ts @@ -1,11 +1,13 @@ import Router from '@koa/router' import path from 'path' import fs from 'fs-extra' +import os from 'os' import { ROOT_DIR } from './constants' import { spawnSync } from 'child_process' import { getMeta } from './controllers' const router = new Router() +const cmdSuffix = os.platform() === 'win32' ? '.cmd' : '' router.get('/', (ctx) => { ctx.body = 'Hello' @@ -36,7 +38,7 @@ router.post('/run/:trans', async (ctx) => { const input = ctx.request.body const script = path.resolve(__dirname, 'transfrom.ts') - const result = spawnSync('ts-node', ['-T', script, name], { + const result = spawnSync(`ts-node${cmdSuffix}`, ['-T', script, name], { input, encoding: 'utf-8', }) From 52ac604414e35f776674f66d9549b6da5320b038 Mon Sep 17 00:00:00 2001 From: ygj6 Date: Fri, 28 May 2021 18:08:21 +0800 Subject: [PATCH 2/3] fix: update run playground script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c8df4cb..77b7018 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "scripts": { "build": "tsc", "prepublishOnly": "tsc", - "playground": "npm -C ./playground run dev", + "playground": "npm run build && cd ./playground && npm install && npm run dev", "test": "jest" }, "repository": { From 278a00e401a3608549cfe90b9d2b96a8dcc6d0ea Mon Sep 17 00:00:00 2001 From: ygj6 Date: Tue, 20 Jul 2021 10:01:05 +0800 Subject: [PATCH 3/3] Update package.json Co-authored-by: Haoqun Jiang --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 77b7018..c8df4cb 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "scripts": { "build": "tsc", "prepublishOnly": "tsc", - "playground": "npm run build && cd ./playground && npm install && npm run dev", + "playground": "npm -C ./playground run dev", "test": "jest" }, "repository": {