From 730ba1af3fa8d03a57e0df6a4dfeba7d19ed8ed1 Mon Sep 17 00:00:00 2001 From: Valerie Date: Sun, 25 Jul 2021 21:07:10 -0400 Subject: [PATCH] idk stuff that should be defaults --- .vscode/tasks.json | 31 +++++++++++++++++++++++++++++-- src/hot-index.ts | 14 ++++++++++---- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index e5264e2..21b3aa1 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -23,7 +23,10 @@ "problemMatcher": { "base": "$tsc-watch", "applyTo": "allDocuments" - } + }, + "dependsOn": [ + "install deps" + ] }, { "label": "dev", @@ -41,6 +44,27 @@ "panel": "shared", "group": "main" }, + "problemMatcher": [], + "dependsOn": [ + "install deps" + ] + }, + { + "label": "install deps", + "type": "npm", + "script": "install", + "isBackground": true, + "group": "build", + "runOptions": { + "runOn": "folderOpen" + }, + "presentation": { + "reveal": "never", + "echo": false, + "focus": false, + "panel": "shared", + "group": "main" + }, "problemMatcher": [] }, { @@ -59,7 +83,10 @@ "panel": "shared", "group": "main" }, - "problemMatcher": [] + "problemMatcher": [], + "dependsOn": [ + "install deps" + ] } ] } \ No newline at end of file diff --git a/src/hot-index.ts b/src/hot-index.ts index a3c3db1..a49d83c 100644 --- a/src/hot-index.ts +++ b/src/hot-index.ts @@ -11,7 +11,7 @@ import chalk from 'chalk'; ipc.config.silent = true; -const exec = 'yarn'; +const exec = 'yarn' + (process.platform === "win32" ? '.cmd' : ''); const args = [ 'start' ] @@ -31,7 +31,9 @@ let proc: ChildProcess = null; function startProcess() { proc = spawn(exec, args, { - stdio: 'inherit' + stdio: 'inherit', + cwd: process.cwd(), + env: process.env }); console.log(`[${proc.pid}] ${chalk.grey(`${exec} ${args.join(' ')}`)}`); proc.on('exit', () => { @@ -55,8 +57,12 @@ async function killProcess() { } async function restart() { - await killProcess(); - startProcess(); + if(proc) { + await killProcess(); + startProcess(); + } else { + startProcess(); + } } startProcess();