use global tsc when local tsc not found

This commit is contained in:
chemzqm 2019-10-05 22:01:18 +08:00
parent d64d956388
commit 2b9c89822d

View file

@ -118,19 +118,19 @@ export default class WatchProject implements Disposable {
let res = await workspace.findUp(['node_modules']) let res = await workspace.findUp(['node_modules'])
let root: string let root: string
let cmd: string let cmd: string
// let root: string if (res) {
if (!res) {
if (executable('tsc')) {
cmd = 'tsc'
root = workspace.cwd
}
} else {
let file = path.join(path.dirname(res), 'node_modules/.bin/tsc') let file = path.join(path.dirname(res), 'node_modules/.bin/tsc')
if (fs.existsSync(file)) { if (fs.existsSync(file)) {
cmd = './node_modules/.bin/tsc' cmd = './node_modules/.bin/tsc'
root = path.dirname(res) root = path.dirname(res)
} }
} }
if (!cmd) {
if (executable('tsc')) {
cmd = 'tsc'
root = workspace.cwd
}
}
if (!cmd) { if (!cmd) {
workspace.showMessage(`Local & global tsc not found`, 'error') workspace.showMessage(`Local & global tsc not found`, 'error')
return return