2.0.3 • Published 8 years ago
@carrd/tasks v2.0.3
A task runner using ES2015 syntax
It uses babel
to compile the code.
Task example
./tasks/echo.js
- output the source of the given file
import readFile from 'fs'
import join from 'path'
export default function * (options, run) {
if (!options.path) {
return console.error('Missing file path')
}
let source = yield (done) => { readFile(options.path, 'utf8', done) }
console.log(source)
}
Run from terminal:
$ task echo --path=./tasks/echo.js
Run programmatically:
var co = require('co')
var task = require('@card/tasks')
co(function * () {
yield task('echo', { some: 'options' })
})
Lookup formula
task setup --config=./file.json
- looks for a file
./tasks/setup.js
- looks for a file
./tasks.js
and for an exported function namedsetup