mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Add inline action for running 'debug scripts'
This commit is contained in:
parent
7dd1326e5b
commit
5d8467dffe
|
@ -53,7 +53,11 @@
|
|||
},
|
||||
{
|
||||
"command": "npm.debugScript",
|
||||
"title": "%command.debug%"
|
||||
"title": "%command.debug%",
|
||||
"icon": {
|
||||
"light": "resources/light/debug.svg",
|
||||
"dark": "resources/dark/debug.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command": "npm.openScript",
|
||||
|
@ -93,11 +97,20 @@
|
|||
"group": "navigation@2"
|
||||
},
|
||||
{
|
||||
"command": "npm.runScript",
|
||||
"command": "npm.runScript",
|
||||
"when": "view == npm && viewItem == script",
|
||||
"group": "inline"
|
||||
},
|
||||
{
|
||||
"command": "npm.runScript",
|
||||
"when": "view == npm && viewItem == debugScript",
|
||||
"group": "inline"
|
||||
},
|
||||
{
|
||||
"command": "npm.debugScript",
|
||||
"when": "view == npm && viewItem == debugScript",
|
||||
"group": "inline"
|
||||
}, {
|
||||
"command": "npm.debugScript",
|
||||
"when": "view == npm && viewItem == script",
|
||||
"group": "navigation@3"
|
||||
|
|
7
extensions/npm/resources/dark/debug.svg
Normal file
7
extensions/npm/resources/dark/debug.svg
Normal file
|
@ -0,0 +1,7 @@
|
|||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="12" height="12" style="fill:#C5C5C5;fill-opacity:1;" viewBox="0 0 512 512">
|
||||
<title></title>
|
||||
<g id="icomoon-ignore">
|
||||
</g>
|
||||
<path d="M512 288v-32h-96.645c-2.931-36.343-15.893-69.513-35.835-96.125h80.972l35.030-140.12-31.045-7.761-28.97 115.88h-87.34c-0.446-0.347-0.898-0.687-1.349-1.028 3.355-9.751 5.181-20.211 5.181-31.097 0.001-52.88-42.979-95.749-95.999-95.749s-96 42.869-96 95.75c0 10.886 1.825 21.346 5.181 31.097-0.45 0.342-0.902 0.681-1.349 1.028h-87.34l-28.97-115.88-31.045 7.761 35.030 140.12h80.972c-19.942 26.611-32.903 59.781-35.834 96.124h-96.645v32h96.685c1.901 22.832 7.754 44.406 16.819 63.875h-61.996l-35.030 140.119 31.045 7.762 28.97-115.881h56.177c29.346 39.016 73.698 63.875 123.33 63.875s93.983-24.859 123.331-63.875h56.177l28.97 115.881 31.045-7.762-35.030-140.119h-61.996c9.065-19.469 14.918-41.043 16.818-63.875h96.685z"></path>
|
||||
</svg>
|
After Width: | Height: | Size: 953 B |
7
extensions/npm/resources/light/debug.svg
Normal file
7
extensions/npm/resources/light/debug.svg
Normal file
|
@ -0,0 +1,7 @@
|
|||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="12" height="12" style="fill:#464D46;fill-opacity:1;" viewBox="0 0 512 512">
|
||||
<title></title>
|
||||
<g id="icomoon-ignore">
|
||||
</g>
|
||||
<path d="M512 288v-32h-96.645c-2.931-36.343-15.893-69.513-35.835-96.125h80.972l35.030-140.12-31.045-7.761-28.97 115.88h-87.34c-0.446-0.347-0.898-0.687-1.349-1.028 3.355-9.751 5.181-20.211 5.181-31.097 0.001-52.88-42.979-95.749-95.999-95.749s-96 42.869-96 95.75c0 10.886 1.825 21.346 5.181 31.097-0.45 0.342-0.902 0.681-1.349 1.028h-87.34l-28.97-115.88-31.045 7.761 35.030 140.12h80.972c-19.942 26.611-32.903 59.781-35.834 96.124h-96.645v32h96.685c1.901 22.832 7.754 44.406 16.819 63.875h-61.996l-35.030 140.119 31.045 7.762 28.97-115.881h56.177c29.346 39.016 73.698 63.875 123.33 63.875s93.983-24.859 123.331-63.875h56.177l28.97 115.881 31.045-7.762-35.030-140.119h-61.996c9.065-19.469 14.918-41.043 16.818-63.875h96.685z"></path>
|
||||
</svg>
|
After Width: | Height: | Size: 953 B |
|
@ -72,6 +72,9 @@ class NpmScript extends TreeItem {
|
|||
constructor(context: ExtensionContext, packageJson: PackageJSON, task: Task) {
|
||||
super(task.name, TreeItemCollapsibleState.None);
|
||||
this.contextValue = 'script';
|
||||
if (task.group && task.group === TaskGroup.Rebuild) {
|
||||
this.contextValue = 'debugScript';
|
||||
}
|
||||
this.package = packageJson;
|
||||
this.task = task;
|
||||
this.command = {
|
||||
|
@ -141,7 +144,7 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
|
|||
workspace.executeTask(script.task);
|
||||
}
|
||||
|
||||
private async extractDebugArg(scripts: any, task: Task): Promise<[string, number] | undefined> {
|
||||
private extractDebugArg(scripts: any, task: Task): [string, number] | undefined {
|
||||
let script: string = scripts[task.name];
|
||||
|
||||
let match = script.match(/--(inspect|debug)(-brk)?(=(\d*))?/);
|
||||
|
|
|
@ -157,6 +157,11 @@ function isExcluded(folder: WorkspaceFolder, packageJsonUri: Uri) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function isDebugScript(script: string): boolean {
|
||||
let match = script.match(/--(inspect|debug)(-brk)?(=(\d*))?/);
|
||||
return match !== null;
|
||||
}
|
||||
|
||||
async function provideNpmScriptsForFolder(packageJsonUri: Uri): Promise<Task[]> {
|
||||
let emptyTasks: Task[] = [];
|
||||
|
||||
|
@ -183,6 +188,9 @@ async function provideNpmScriptsForFolder(packageJsonUri: Uri): Promise<Task[]>
|
|||
if (prePostScripts.has(each)) {
|
||||
task.group = TaskGroup.Clean; // hack: use Clean group to tag pre/post scripts
|
||||
}
|
||||
if (isDebugScript(scripts![each])) {
|
||||
task.group = TaskGroup.Rebuild; // hack: use Rebuild group to tag debug scripts
|
||||
}
|
||||
result.push(task);
|
||||
});
|
||||
// always add npm install (without a problem matcher)
|
||||
|
|
Loading…
Reference in a new issue