enable running individual npm scripts in the containing folder#79960
enable running individual npm scripts in the containing folder#79960egamma merged 7 commits intomicrosoft:masterfrom
Conversation
|
@helen3141 thank you for the PR (sorry for the delayed review, but there was no corresponding issue with a feature request filed). The PR currently includes no description. Can you please provide more background what the feature does, why is it needed, and how it can be tested? |
|
Hi @egamma! The feature request originates from our team's need to easily view and run custom scripts written in the The idea is that users can select any folder in the Explorer pane to view the custom scripts within the folder's Then a command palette will pop up with all of the custom scripts within that folder: You can run this branch in Debug mode with the option 'Launch VS Code' selected. The default setting is that this feature is enabled. You can toggle the feature on/off. Go to File>Preferences>Settings> click the 'Extensions' drop down, click 'Npm' and untick the box 'Enable Run From Folder Context Menu': When the feature is enabled you can test it. Open any folder/project. The extension will check for custom scripts in the This check leverages the code already in the extension, and is executed every time a folder is right-clicked in the Explorer pane. This could potentially be computationally expensive if the project is very large with many nested package.json files and I haven't stress tested/optimized for an extreme use case like that. When the 'Select npm Scripts to Run...' option from the context menu is selected, all the custom scripts available in the folder will be listed in the command palette that pops up. Scripts available from the When the user selects an option from the command palette, that particular script will run. If you have a terminal visible, you should be able to see the console output of that script. Thank you for your feedback and please feel free to comment with any more questions/thoughts you may have! |
There was a problem hiding this comment.
@helen3141 thank you for the additional background. I've reviewed the PR.
In general the default value of the setting to enable the context menu should be false. The NPM extension is bundled with VS Code and it has to be defensive with regard to contributing to the context menu, given that not all workspaces are node based, e.g., think of a Python workspace.
extensions/npm/src/commands.ts
Outdated
| } | ||
| }); | ||
| let result = await vscode.window.showQuickPick(Object.keys(taskMap).sort(), { | ||
| placeHolder: `Run scripts on folder ${folderInfo.fsPath}...`, |
There was a problem hiding this comment.
The quick pick should have a title 'Run npm Script in Folder' and the place holder should be 'Select script'
There was a problem hiding this comment.
Thanks for your helpful feedback! I was able to implement all except the title for the quick pick as I don't think there is a property for showQuickPick
…che if available instead of creating new tasks
|
@helen3141 thanks again 🌷 for the PR it is now merged in. I've removed the code that leverages the tasks cache, it still requires to do a search on the file system and it is more tricky to get it right in all the cases.
Correct this option is not available for the simple showQuickPick API, you have to create a QuickPick by yourself to get at this option, pls see this commit 7485ffd for how it can be done. This commit also includes some wording tweaks. One tweaks I made was to simplify the setting from |
|
@helen3141 the feature is now available in the insiders build. |
No description provided.