Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
enable running individual npm scripts in the containing folder #79960
@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?
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!
egamma left a 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
@helen3141 thanks again
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