(inFolder?: string)
| 25 | * @param inFolder - Optionally scopes lookups to the given workspace folder |
| 26 | */ |
| 27 | export async function debugNpmScript(inFolder?: string) { |
| 28 | const scripts = await findScripts(inFolder ? [inFolder] : undefined); |
| 29 | if (!scripts) { |
| 30 | return; // cancelled |
| 31 | } |
| 32 | |
| 33 | // For multi-root workspaces, prefix the script name with the workspace |
| 34 | // directory name so the user knows where it's coming from. |
| 35 | const multiDir = scripts.some(s => s.directory !== scripts[0].directory); |
| 36 | const quickPick = vscode.window.createQuickPick<ScriptPickItem>(); |
| 37 | quickPick.items = scripts.map(script => ({ |
| 38 | script, |
| 39 | label: multiDir ? `${path.basename(script.directory)}: ${script.name}` : script.name, |
| 40 | description: script.command, |
| 41 | })); |
| 42 | |
| 43 | quickPick.onDidAccept(() => { |
| 44 | const { script } = quickPick.selectedItems[0]; |
| 45 | const workspaceFolder = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(script.directory)); |
| 46 | runCommand( |
| 47 | vscode.commands, |
| 48 | Commands.CreateDebuggerTerminal, |
| 49 | getRunScriptCommand(script.name, workspaceFolder), |
| 50 | workspaceFolder, |
| 51 | { cwd: script.directory }, |
| 52 | ); |
| 53 | |
| 54 | quickPick.dispose(); |
| 55 | }); |
| 56 | |
| 57 | quickPick.show(); |
| 58 | } |
| 59 | |
| 60 | interface IEditCandidate { |
| 61 | path?: string; |
nothing calls this directly
no test coverage detected