mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Fix for #31274 Support for yarn when running detected tasks
This commit is contained in:
parent
10ba78f6f3
commit
1420d41bf8
|
@ -41,17 +41,29 @@
|
|||
"description": "%config.npm.autoDetect%"
|
||||
},
|
||||
"npm.runSilent": {
|
||||
"type": "boolean",
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"scope": "resource",
|
||||
"description": "%config.npm.runSilent%"
|
||||
"description": "%config.npm.runSilent%"
|
||||
},
|
||||
"npm.packageManager": {
|
||||
"scope": "resource",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"npm",
|
||||
"yarn"
|
||||
],
|
||||
"default": "npm",
|
||||
"description": "The package manager used to run scripts"
|
||||
}
|
||||
}
|
||||
},
|
||||
"taskDefinitions": [
|
||||
{
|
||||
"type": "npm",
|
||||
"required": ["script"],
|
||||
"required": [
|
||||
"script"
|
||||
],
|
||||
"properties": {
|
||||
"script": {
|
||||
"type": "string",
|
||||
|
|
|
@ -135,7 +135,7 @@ async function provideNpmScriptsForFolder(folder: vscode.WorkspaceFolder): Promi
|
|||
result.push(task);
|
||||
});
|
||||
// always add npm install (without a problem matcher)
|
||||
result.push(createTask('install', 'install', rootPath, folder, []));
|
||||
// result.push(createTask('install', 'install', rootPath, folder, []));
|
||||
return result;
|
||||
} catch (e) {
|
||||
return emptyTasks;
|
||||
|
@ -148,11 +148,12 @@ function createTask(script: string, cmd: string, rootPath: string, folder: vscod
|
|||
return script;
|
||||
}
|
||||
|
||||
function getNpmCommandLine(folder: vscode.WorkspaceFolder, cmd: string): string {
|
||||
function getCommandLine(folder: vscode.WorkspaceFolder, cmd: string): string {
|
||||
let packageManager = vscode.workspace.getConfiguration('npm', folder.uri).get<string>('packageManager', 'npm');
|
||||
if (vscode.workspace.getConfiguration('npm', folder.uri).get<boolean>('runSilent')) {
|
||||
return `npm --silent ${cmd}`;
|
||||
return `${packageManager} --silent ${cmd}`;
|
||||
}
|
||||
return `npm ${cmd}`;
|
||||
return `${packageManager} ${cmd}`;
|
||||
}
|
||||
|
||||
let kind: NpmTaskDefinition = {
|
||||
|
@ -160,5 +161,5 @@ function createTask(script: string, cmd: string, rootPath: string, folder: vscod
|
|||
script: script
|
||||
};
|
||||
let taskName = getTaskName(script);
|
||||
return new vscode.Task(kind, folder, taskName, 'npm', new vscode.ShellExecution(getNpmCommandLine(folder, cmd), { cwd: rootPath }), matcher);
|
||||
return new vscode.Task(kind, folder, taskName, 'npm', new vscode.ShellExecution(getCommandLine(folder, cmd), { cwd: rootPath }), matcher);
|
||||
}
|
Loading…
Reference in a new issue