mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
added silent setting
This commit is contained in:
parent
6572aacf64
commit
10a5cee648
|
@ -38,6 +38,11 @@
|
|||
],
|
||||
"default": "on",
|
||||
"description": "%config.npm.autoDetect%"
|
||||
},
|
||||
"npm.runSilent": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "%config.npm.runSilent%"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
"config.npm.autoDetect": "Controls whether auto detection of npm scripts is on or off. Default is on."
|
||||
"config.npm.autoDetect": "Controls whether auto detection of npm scripts is on or off. Default is on.",
|
||||
"config.npm.runSilent": "Run npm commands with the `--silent` option"
|
||||
}
|
|
@ -87,8 +87,16 @@ function isTestTask(name: string): boolean {
|
|||
return false;
|
||||
}
|
||||
|
||||
function getNpmCommandLine(script:string): string {
|
||||
if (vscode.workspace.getConfiguration('npm').get<boolean>('runSilent')) {
|
||||
return `npm --silent run ${script}`;
|
||||
}
|
||||
return `npm run ${script}`
|
||||
}
|
||||
|
||||
async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
|
||||
let workspaceRoot = vscode.workspace.rootPath;
|
||||
|
||||
let emptyTasks: vscode.Task[] = [];
|
||||
|
||||
if (!workspaceRoot) {
|
||||
|
@ -100,6 +108,11 @@ async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
|
|||
return emptyTasks;
|
||||
}
|
||||
|
||||
let silent = '';
|
||||
if (vscode.workspace.getConfiguration('npm').get<boolean>('runSilent')) {
|
||||
silent = '--silent';
|
||||
}
|
||||
|
||||
try {
|
||||
var contents = await readFile(packageJson);
|
||||
var json = JSON.parse(contents);
|
||||
|
@ -113,7 +126,7 @@ async function getNpmScriptsAsTasks(): Promise<vscode.Task[]> {
|
|||
type: 'npm',
|
||||
script: each
|
||||
};
|
||||
const task = new vscode.Task(kind, `run ${each}`, 'npm', new vscode.ShellExecution(`npm run ${each}`));
|
||||
const task = new vscode.Task(kind, `run ${each}`, 'npm', new vscode.ShellExecution(getNpmCommandLine(each)));
|
||||
const lowerCaseTaskName = each.toLowerCase();
|
||||
if (isBuildTask(lowerCaseTaskName)) {
|
||||
task.group = vscode.TaskGroup.Build;
|
||||
|
|
Loading…
Reference in a new issue