Extensibility is a wonderful thing [A set of Visual Studio Code tasks for common npm functionality in Node.js and io.js]
Yesterday at its Build conference, Microsoft released the Visual Studio Code editor which is a lightweight, cross-platform tool for building web and cloud applications. I've been using internal releases for a while and highly recommend trying it out!
One thing I didn't know about until yesterday was support for Tasks to automate common steps like build and testing.
As the documentation shows, there's already knowledge of common build frameworks, including gulp for Node.js and io.js.
But for simple Node projects I like to automate via npm's scripts because they're simple and make it easy to integrate with CI systems like Travis.
So I whipped up a simple tasks.json
for Code that handles build, test, and lint for typical npm configurations.
I've included it below for anyone who's interested.
Note: Thanks to metadata, the build and test tasks are recognized as such by Code and easily run with the default hotkeys
Ctrl+Shift+B
andCtrl+Shift+T
.
Enjoy!
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"suppressTaskName": true,
"tasks": [
{
// Build task, Ctrl+Shift+B
// "npm install --loglevel info"
"taskName": "install",
"isBuildCommand": true,
"args": ["install", "--loglevel", "info"]
},
{
// Test task, Ctrl+Shift+T
// "npm test"
"taskName": "test",
"isTestCommand": true,
"args": ["test"]
},
{
// "npm run lint"
"taskName": "lint",
"args": ["run", "lint"]
}
]
}
Updated 2015-05-02: Added --loglevel info
to npm install
for better progress reporting
Updated 2016-02-27: Added isShellCommand
, suppressTaskName
, and updated args
to work with newer versions of VS Code