1.3.0 • Published 7 years ago

run-task v1.3.0

Weekly downloads
17
License
ISC
Repository
github
Last release
7 years ago

run-task

A simple cli task runner. When you would prefer to write code rather than shell scripts in package.json, but would rather not spend a lot of time learning a build tool.

Requires node v4 or newer.

Usage

run-task returns a function that takes an object as an argument. The keys are the names of tasks and the values are functions for those tasks.

  • Write some functions, then pass in the ones you want to be tasks.
// filename: run.js

const tasks = require('run-task')

function foo () {
  console.log('foo')
}

function bar () {
  console.log('bar')
}

function foobar () {
  foo()
  bar()
}

tasks({
  bar,
  foobar
})
  • Execute using node [script] [task].
$ node run foobar
  • If you use JSDoc comments, it will pick up the description. You can also add a description by attaching a description property to the function.
/**
 * This will show up as the task's description on stdout.
 */
function bar () {
  console.log('bar')
}
function bar () {
  console.log('bar')
}

bar.description = "This will show up as the task's description on stdout."
  • You can pass in more than one task.
$ node run bar foobar
  • If you don't provide a task argument, it will list the available tasks.
$ node run
[run] Available tasks:
[run] bar - This will show up as the task's description on stdout.
[run] foobar
  • You can also pass in a -q flag to silence the run-task logging.
$ node run bar -q
bar

That's it. It just runs functions from the command line. There are no assumptions on what kind of tasks you want to run.

Because of this, you'll probably want to require some other modules in your run.js script.

  • There's a lot you can get done with the core api, read the docs
  • Check out a curated list of modules at awesome-nodejs.
  • shelljs is a great tool for tasks (cross-platform *nix commands for node).

Other Suggestions

  • Take advantage of the property shorthand.
  • Name the file containing the tasks run.js so you can use: node run [task].
1.3.0

7 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.0.26

9 years ago

0.0.25

9 years ago

0.0.24

9 years ago

0.0.23

9 years ago

0.0.22

9 years ago

0.0.21

9 years ago

0.0.20

9 years ago