From 2b9c89822de857f8ee9153db303de1ba56dcd441 Mon Sep 17 00:00:00 2001 From: chemzqm Date: Sat, 5 Oct 2019 22:01:18 +0800 Subject: [PATCH] use global tsc when local tsc not found --- src/server/features/watchBuild.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/server/features/watchBuild.ts b/src/server/features/watchBuild.ts index b68b007..741fa54 100644 --- a/src/server/features/watchBuild.ts +++ b/src/server/features/watchBuild.ts @@ -118,19 +118,19 @@ export default class WatchProject implements Disposable { let res = await workspace.findUp(['node_modules']) let root: string let cmd: string - // let root: string - if (!res) { - if (executable('tsc')) { - cmd = 'tsc' - root = workspace.cwd - } - } else { + if (res) { let file = path.join(path.dirname(res), 'node_modules/.bin/tsc') if (fs.existsSync(file)) { cmd = './node_modules/.bin/tsc' root = path.dirname(res) } } + if (!cmd) { + if (executable('tsc')) { + cmd = 'tsc' + root = workspace.cwd + } + } if (!cmd) { workspace.showMessage(`Local & global tsc not found`, 'error') return