mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-10 16:58:55 -05:00
Prep task provider for muiltiroot
This commit is contained in:
@@ -43,16 +43,17 @@ class TscTaskProvider implements vscode.TaskProvider {
|
||||
}
|
||||
|
||||
public async provideTasks(token: vscode.CancellationToken): Promise<vscode.Task[]> {
|
||||
const rootPath = vscode.workspace.rootPath;
|
||||
if (!rootPath) {
|
||||
const folders = vscode.workspace.workspaceFolders;
|
||||
if (!folders || !folders.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const command = await this.getCommand();
|
||||
const rootPath = folders[0].uri;
|
||||
const command = await this.getCommand(rootPath);
|
||||
const projects = await this.getAllTsConfigs(token);
|
||||
|
||||
return projects.map(configFile => {
|
||||
const configFileName = path.relative(rootPath, configFile);
|
||||
const configFileName = path.relative(rootPath.fsPath, configFile);
|
||||
const identifier: TypeScriptTaskDefinition = { type: 'typescript', tsconfig: configFileName };
|
||||
const buildTask = new vscode.Task(identifier, `build ${configFileName}`, 'tsc', new vscode.ShellExecution(`${command} -p "${configFile}"`), '$tsc');
|
||||
buildTask.group = vscode.TaskGroup.Build;
|
||||
@@ -108,11 +109,11 @@ class TscTaskProvider implements vscode.TaskProvider {
|
||||
return Array.from(await this.tsconfigProvider.getConfigsForWorkspace());
|
||||
}
|
||||
|
||||
private async getCommand(): Promise<string> {
|
||||
private async getCommand(root: vscode.Uri): Promise<string> {
|
||||
const platform = process.platform;
|
||||
if (platform === 'win32' && await exists(path.join(vscode.workspace.rootPath!, 'node_modules', '.bin', 'tsc.cmd'))) {
|
||||
if (platform === 'win32' && await exists(path.join(root.fsPath, 'node_modules', '.bin', 'tsc.cmd'))) {
|
||||
return path.join('.', 'node_modules', '.bin', 'tsc.cmd');
|
||||
} else if ((platform === 'linux' || platform === 'darwin') && await exists(path.join(vscode.workspace.rootPath!, 'node_modules', '.bin', 'tsc'))) {
|
||||
} else if ((platform === 'linux' || platform === 'darwin') && await exists(path.join(root.fsPath, 'node_modules', '.bin', 'tsc'))) {
|
||||
return path.join('.', 'node_modules', '.bin', 'tsc');
|
||||
} else {
|
||||
return 'tsc';
|
||||
|
||||
Reference in New Issue
Block a user