cha
Make task chaining.
Cha allows tasks to be connected together into a chain that makes better readability and easier to maintain.
Getting Started
Installing cha via NPM, this will install the latest version of cha in your project folder
and adding it to your devDependencies
in package.json
:
npm install cha --save-dev
Touch a tasks file and naming whatever you love like build.js
:
// Load cha library.var cha = // Load tasks directory with an index.js that exports ./tasks/glob.js, etc.var tasks = // Register tasks that should chaining.cha // Define task via chaining calls.
Add a arbitrary command to the scripts
object:
To run the command we prepend our script name with run:
$ npm run build > cha@0.0.1 build> node ./test/build request http://underscorejs.org/underscore-min.jsconcat ./test/fixtures/bar.js,./test/fixtures/foo.js,http://underscorejs.org/underscore-min.jswrite ./out/foobar.jscopy out/foobar.js > ./out/foobar2.js
How to set file watcher?
Install watch extension for cha:
npm install cha-watch --save-dev
Once the extension has been installed, it should required inside your scripts with this line of JavaScript:
chawatch =
Example script:
var cha = var tasks = // Require watch extension.chawatch = cha // Start watcher.cha
To run the command we prepend our script name with run:
$ npm run watch > cha@0.0.1 watch> node ./test/watch read /test/fixtures/coffee/bar.coffeeread /test/fixtures/coffee/foo.coffeeconcat /test/fixtures/coffee/bar.coffee,/test/fixtures/coffee/foo.coffeewrite ./out/foobar3.js
How to set targets?
Install target extension for cha:
npm install cha-target --save-dev
Once the extension has been installed, it should required inside your scripts with this line of JavaScript:
chatarget =
Example script:
var cha = var tasks = // Require target extension.chatarget = cha { source } // Setting a "dev" target.chatarget'dev' { // Require watch extension. chawatch = // Start watcher. cha} // Setting a "dist" target.chatarget'dist' { } // Setting a "all" target.chatarget'all' 'dev' 'dist' // Running target.// cha.target.run('all')
Add a arbitrary command to the scripts
object:
To run the command we prepend our script name with run:
$ npm run dev > cha@0.1.1 dev /cha> node ./test/target dev read /cha/test/fixtures/coffee/bar.coffeeread /cha/test/fixtures/coffee/foo.coffeeconcat /cha/test/fixtures/coffee/bar.coffee,/cha/test/fixtures/coffee/foo.coffeewrite ./out/foobar3.js
How to enjoy cha expressions?
// Load cha library.var cha = var tasks = // Register tasks that should chaining.cha // Start with cha expressions.
To run the command we prepend our script name with run:
$ npm run expr > cha@0.0.1 expr> node ./test/expr request http://underscorejs.org/underscore-min.jsconcat http://underscorejs.org/underscore-min.jswrite ./out/foobar.js
How to setting task?
// Load cha library.var cha = var tasks = // Register tasks that should chaining.cha // Start with cha expressions.
How to creating custom task?
Chaining task should based on the Task.JS specification.
The following example creating a task concatenate files from the inputs. It extend from Execution
class and define execute
method:
var _ = ;var fs = ;var path = ;var Execution = ;var Record = ; var Concat = Execution; moduleexports = Concat
Release History
- 2014-05-19 0.2.1 Task accept
settings
param with general options. - 2014-05-18 0.2.0 Remove Internal methods.
- 2014-03-17 0.1.2 Extensions for cha.
- 2014-03-10 0.1.1 Custom tasks could override internal methods.
- 2014-03-05 0.1.0 Initial release.