A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/jonschlinkert/composer below:

jonschlinkert/composer: API-first task runner with three methods: task, run and watch.

API-first task runner with three methods: task, run and watch.

Please consider following this project's author, Brian Woodward, and consider starring the project to show your ❤️ and support.

(TOC generated by verb using markdown-toc)

Install with npm:

$ npm install --save composer

Heads up the .watch method was removed in version 0.11.0. If you need watch functionality, use base-tasks and base-watch.

const Composer = require('composer');
const composer = new Composer();

composer.task('default', cb => {
  console.log('Task: ', this.name);
  cb();
});

composer.build('default')
  .then(() => console.log('done!'))
  .catch(console.error);

Example

const composer = new Composer();

Dependencies may also be specified as a glob pattern. Be aware that the order cannot be guarenteed when using a glob pattern.

Params

Example

// register task "site" with composer
app.task('site', ['styles'], function() {
  return app.src('templates/pages/*.hbs')
    .pipe(app.dest('_gh_pages'));
});

Params

Example

app.build('default', function(err, results) {
  if (err) return console.error(err);
  console.log(results);
});

Params

Example

app.task('foo', function(done) {
  console.log('this is foo');
  done();
});

const fn = app.series('foo', function bar(done) {
  console.log('this is bar');
  done();
});

fn(function(err) {
  if (err) return console.error(err);
  console.log('done');
});
//=> this is foo
//=> this is bar
//=> done

Params

Example

app.task('foo', function(done) {
  setTimeout(function() {
    console.log('this is foo');
    done();
  }, 500);
});

const fn = app.parallel('foo', function bar(done) {
  console.log('this is bar');
  done();
});

fn(function(err) {
  if (err) return console.error(err);
  console.log('done');
});
//=> this is bar
//=> this is foo
//=> done

When an individual task is run, a new Run instance is created with start, end, and duration information. This run object is emitted with some events and also exposed on the task instance as the .runInfo property.

The run instance has the the following properties

.date

The .date property is an object containing the .start and .end date timestamps created with new Date().

.hr

The .hr property is an object containing the .start, .end and .duration properties that are created by using process.hrtime(). These properties are the actual arrays returned from process.hrtime(). There is also .diff and .offset computed properties that use the other properties to calculate the difference between .start and .end times (.diff) and the offset (error for time calculations) between the .duration and the .diff (this is usually very small).

.duration

The .duration property is a computed property that uses pretty-time to format the .hr.duration value into a human readable format.

composer is an event emitter that may emit the following events:

This event is emitted when the build is starting and when it's finished. The event emits an object containing the build runtime information.

app.on('build', build => {});

This event is emitted when the task is registered, starting, and when it's finished. The event emits 2 arguments, the current instance of the task object and an object containing the task runtime information.

app.on('task', (task, run) => {});

This event is emitted when an error occurrs during a build. The event emits an Error object with extra properties for debugging the build and task that were running when the error occurred.

app.on('error', err => {});
app.task('foo', function(cb) {
  console.log(this.runInfo.duration);
});
Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Running Tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test
Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

You might also be interested in these projects:

Brian Woodward

Copyright © 2018, Brian Woodward. Released under the MIT License.

This file was generated by verb-generate-readme, v0.6.0, on March 01, 2018.

  1. When `build.status` is `finished`, the `.hr` object also has `.duration` and `.diff` properties containing timing information calculated using `process.hrtime`.
  2. When `task.status` is `finished`, the `.hr` object also has `.duration` and `.diff` properties containing timing information calculated using `process.hrtime`.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4