🚀 Minimalistic task runner on steroids!
MIT License
Minimalistic task runner on steroids. Write scripts using JSON5 or ES6 JavaScript modules.
scripts
: You can just copy & paste them to the launch filenode_modules/.bin
like package.json scripts
npm install --save-dev npm-launch
scripts
in package.json are a messnpm
prints ~25 lines of non-helpful disclaimersgulp
& grunt
instead need 100 lines of code for things that take less than five lines on the command lineBut no more! Let's take the sample launch file from the screencast before and use
it in our package.json
:
Here we go, everything is clean and concise now!
A clean and short package.json. Commented tasks. Concurrency support out-of-the-box.
// File: launch.scripts.json5
{
build: "webpack -c webpack-config.production.js",
test: "run-parallel lint mocha",
//////////
// Hooks:
prepush: "run build && run test",
//////////////////
// Testing tasks:
lint: "standard lib/**/*.js",
mocha: "mocha"
}
$ launch build test # run tasks "build" and "test"
# or
$ launch -f path/to/launch-file build test
Features:
run-parallel <task1> <task2> ...
(or short run-p
)// File: launch.scripts.js
const shell = module.parent.exports.shell
const delay = 1500
// Define a task "npmPruneList"
export async function npmPruneList () {
// Execute `npm prune`
await shell('npm prune')
// Then execute `npm list`
await shell('npm list')
}
// Define a task "wasteSomeTime"
export function wasteSomeTime () {
return new Promise((resolve) => {
setTimeout(() => resolve(), delay)
})
}
// Define a task "default" that will just run "npmPruneList" & "wasteSomeTime" sequentially
export default [ npmPruneList, wasteSomeTime ]
Features:
async
/await
are available out-of-the-boxRun the tasks build
and test
:
launch build test
Run the default
task:
launch
List all available tasks:
launch --list
Print CLI usage help text:
launch --help
launch.scripts.js
/launch.scripts.json
/launch.scripts.json5
$ launch myTask
you can also run $ launch my-task
These limitations only apply if your launch file contains custom JS code rather than JSON tasks.
Tasks called by code are tracked and displayed, but not as a checkmark list, but just as a hint which one is currently run. It's simple: In this case we cannot create a list of subtasks beforehand, since there is no way to know which sub-tasks the function is going to call.
If you call console.log()
(or similar) in your launch file then the checkmark
list will probably be corrupted.
See CHANGELOG.md or Releases Page for more details.
This library is released under the terms of the MIT license. See LICENSE for details.