tasco
Modern task runner / build tool.
Last updated 3 years ago by rem .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install tasco 
SYNC missed versions from official npm registry.

tasco

NPM version NPM downloads Build Status donate

Install

npm i -g tasco

Usage

Populate a taskfile.js in your project:

// The default task
export default async function (t) {
  await t.parallel('css', 'js')
}

// Transform css using PostCSS
// Using postcss-cssnext
export async function css(t) {
  await t
    .input('./css/*.css')
    .postcss()
    .output('./dist/css/')
}

// Transform js using Babel
// Using babel-preset-es2015
export async function js(t) {
  await t
    .input('./js/*.js')
    .babel()
    .output('./dist/js/')
}

Then fire the default task from command-line:

tasco
# or specific task
tasco js

Another neat feature, run tasco help to get information about all tasks.

You can using JavaScript comments to describe the tasks, it should be present right before the task. Both single-line and multi-line comments are supported. In tasco help only the first line of the description will be print, you can read full description for specific task via tasco help <taskname>

The description also supports templating.

Use a plugin

Just install a plugin in your project and it will be automatically loaded, plugin name follows the tasco-[name] convention.

Check out the doc for building a plugin.

API

templating

You can use {{ expression }} in task description, we use vegito under the hood, for example:

// this task builds {{ chalk.yellow('js files') }}
export async function js(t) {
  await t.input().babel().output() //...
}

Available variables:

  • chalk: The chalk module.

t.input(...globs)

t.input([globs]) or t.input(globA, globB...)

t.output(destDir)

The directory to write files.

t.parallel(tasks)

Run multiple tasks in parallel.

t.sequence(tasks)

Run multiple tasks in sequence.

t.single(task)

Run a single task.

plugin

plugin.name

Type: string
Requried: true

The property on t to bind plugin.

For example, if name is babel then you can use t.babel

plugin.pipe

Type: function
Required: true

The pipe function, eg, add a piper to compile js using Babel:

module.exports = {
  name: 'babel',
  pipe(options) {
    this.files.forEach((file, index) => {
      this.files[index].content = babel
        .transform(this.files[index].content, options)
        .code
    })
  }
}

The pipe function should return a Promise or perform synchronize operations.

Register plugin

Plugin can be installed from npm and automatically loaded. For testing plugin locally, you can use t.use function:

const plugin = {
  name: 'doSomething', 
  pipe() {}
}

export async function build(t) {
  t.use(plugin)
  await t.input().doSomething().output()
}

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

tasco © egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).

egoistian.com · GitHub @egoist · Twitter @rem_rin_rin

Current Tags

  • 0.4.0                                ...           latest (3 years ago)

6 Versions

  • 0.4.0                                ...           3 years ago
  • 0.3.1                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.0                                ...           3 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 6
Dependencies (14)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |