promise-task-runner
- This readme covers a few basics. For anything more, please see [the wiki](https://github.com/olsonpm/promise-task-runner/wiki). I have spent a lot of effort into making the wiki useful, so please give it a shot. - To avoid confusion, the abbreviation
Last updated 6 years ago by olsonpm .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install promise-task-runner 
SYNC missed versions from official npm registry.

promise-task-runner

  • This readme covers a few basics. For anything more, please see the wiki. I have spent a lot of effort into making the wiki useful, so please give it a shot.
  • To avoid confusion, the abbreviation 'ptr' is for promise-task-runner.

First of all, why does promise-task-runner exist?

Because I liked the concept of a streaming build-system as made popular by Gulp, but I didn't like its task management library. I thought dependencies would be best handled via promises, I thought command-line option support should be built-in, and I thought tasks should be able to pass results down to other dependent tasks.

Why would I want to use this tool?

You'll find this tool useful if you're more comfortable managing task dependencies via promises, or want tasks to pass results down to dependent tasks. I also hope you find ptr easy to pick up, as I've spent a lot of effort organizing the documentation for ease of use. There are plenty of examples and an explicit API.

What does a task look like?

You declare a task using the PromiseTask object

// tasks/scripts.js
var ptr = require('promise-task-runner');
var PromiseTask = ptr.PromiseTask
var scripts = new PromiseTask()
  .id('scripts')
  .task(function() {
    // task logic
  });

Then add it to a PromiseTaskContainer and export the container

// tasks/scripts.js
...
var PromiseTaskContainer = ptr.PromiseTaskContainer;
var ptc = new PromiseTaskContainer();
ptc.addTask(scripts);
module.exports = ptc;

Now in your root project folder, you can call:

$ ptr run-task scripts
Finished running task 'scripts' in 0.2 seconds

Great, how do I get started?

The wiki should get you on your way

What's with the weird (fluent) api?

You'll notice that instead of passing in constructor function parameters, you pass them in via property functions that act both as getters and setters. You set the property by passing a parameter, and you get the property by calling it with no parameters. Thus, using the task 'scripts' from above:

scripts.id(); // returns 'scripts'
scripts.id('scripts2'); // sets id to 'scripts2' and returns itself, creating a fluent api

scripts
  .id('scripts')
  .task(function() { ... });

It's intuitive and removes ambiguity between what function parameters are, what order they need to be passed, and how optional parameter logic is handled. The API preface gives a little more detail.

Current Tags

  • 0.0.2                                ...           latest (6 years ago)

2 Versions

  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (9)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |