Add support for tsconfigPath setting (#286)

* Add support for tsconfigPath setting

* Fix a typo, add config option to package.json

* formatting

* Update setting description in package.json

Co-authored-by: Nate Roling <roling@cartegraph.com>
This commit is contained in:
nateroling 2021-06-06 22:29:30 -05:00 committed by GitHub
parent fd957b20f9
commit d24d75de9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -114,6 +114,11 @@
"default": true,
"description": "Enable tsserver extension"
},
"tsserver.tsconfigPath": {
"type": "string",
"default": "tsconfig.json",
"description": "Path to tsconfig file for the `tsserver.watchBuild` command. Defaults to `tsconfig.json`."
},
"tsserver.locale": {
"type": [
"string",

View file

@ -32,6 +32,7 @@ export default class WatchProject implements Disposable {
) {
this.statusItem = window.createStatusBarItem(1, { progress: true })
let task = this.task = workspace.createTask('TSC')
this.disposables.push(commands.registerCommand(WatchProject.id, async () => {
let opts = this.options = await this.getOptions()
await this.start(opts)
@ -117,15 +118,18 @@ export default class WatchProject implements Disposable {
window.showMessage(`Local & global tsc not found`, 'error')
return
}
let find = await workspace.findUp(['tsconfig.json'])
const tsconfigPath = workspace.getConfiguration('tsserver').get<string>('tsconfigPath', 'tsconfig.json');
let find = await workspace.findUp([tsconfigPath])
if (!find) {
window.showMessage('tsconfig.json not found!', 'error')
window.showMessage(`${tsconfigPath} not found!`, 'error')
return
}
let root = path.dirname(find)
return {
cmd: tscPath,
args: ['-p', 'tsconfig.json', '--watch', 'true', '--pretty', 'false'],
args: ['-p', tsconfigPath, '--watch', 'true', '--pretty', 'false'],
cwd: root
}
}