MCPcopy Create free account
hub / github.com/Snapchat/Valdi / debugNpmScript

Function debugNpmScript

valdi/vscode_debugger/src/ui/debugNpmScript.ts:27–58  ·  view source on GitHub ↗
(inFolder?: string)

Source from the content-addressed store, hash-verified

25 * @param inFolder - Optionally scopes lookups to the given workspace folder
26 */
27export 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
60interface IEditCandidate {
61 path?: string;

Callers

nothing calls this directly

Calls 7

runCommandFunction · 0.90
getRunScriptCommandFunction · 0.90
findScriptsFunction · 0.85
fileMethod · 0.80
disposeMethod · 0.65
showMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected