{"id":25180652,"url":"https://github.com/base-repos/base-task","last_synced_at":"2025-07-29T18:02:48.089Z","repository":{"id":57189233,"uuid":"46495392","full_name":"base-repos/base-task","owner":"base-repos","description":"base plugin that provides a very thin wrapper around composer for adding task methods to your application.","archived":false,"fork":false,"pushed_at":"2018-11-22T08:02:38.000Z","size":42,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-19T22:27:50.140Z","etag":null,"topics":["app","assemble","base","composer","generate","plugin","toolkit","update","verb"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/base-repos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-19T13:55:06.000Z","updated_at":"2025-01-31T00:39:08.000Z","dependencies_parsed_at":"2022-09-15T06:21:25.819Z","dependency_job_id":null,"html_url":"https://github.com/base-repos/base-task","commit_stats":null,"previous_names":["jonschlinkert/base-tasks","base-repos/base-task"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/base-repos/base-task","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base-repos%2Fbase-task","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base-repos%2Fbase-task/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base-repos%2Fbase-task/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base-repos%2Fbase-task/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/base-repos","download_url":"https://codeload.github.com/base-repos/base-task/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base-repos%2Fbase-task/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267497538,"owners_count":24097179,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["app","assemble","base","composer","generate","plugin","toolkit","update","verb"],"created_at":"2025-02-09T16:19:13.262Z","updated_at":"2025-07-29T18:02:48.027Z","avatar_url":"https://github.com/base-repos.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# base-task [![NPM version](https://img.shields.io/npm/v/base-task.svg?style=flat)](https://www.npmjs.com/package/base-task) [![NPM monthly downloads](https://img.shields.io/npm/dm/base-task.svg?style=flat)](https://npmjs.org/package/base-task) [![NPM total downloads](https://img.shields.io/npm/dt/base-task.svg?style=flat)](https://npmjs.org/package/base-task) [![Linux Build Status](https://img.shields.io/travis/base/base-task.svg?style=flat\u0026label=Travis)](https://travis-ci.org/base/base-task)\n\n\u003e Base plugin that provides a very thin wrapper around [https://github.com/doowb/composer](https://github.com/doowb/composer) for adding task methods to your Base application.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save base-task\n```\n\n## Usage\n\n```js\nconst Base = require('base');\nconst tasks = require('base-task');\nconst base = new Base();\n\nbase.use(tasks());\n\n/**\n * Define tasks\n */\n\nbase.task('foo', cb =\u003e {\n  console.log('this is foo!');\n  cb();\n});\n\nbase.task('bar', cb =\u003e {\n  console.log('this is bar!');\n  cb();\n});\n\n/**\n * Build tasks\n */\n\nbase.build(['foo', 'bar'])\n  .then(() =\u003e {\n    // this is foo!\n    // this is bar!\n    console.log('done!');\n  })\n  .catch(console.error)\n```\n\nSee the [composer](https://github.com/doowb/composer) documentation for more details, or to create bug reports related to running or registering tasks.\n\n## API\n\n### .task\n\nRegister a task\n\n**Params**\n\n* `name` **{String}**: Task name to register (tasks are cached on `app.tasks`)\n* `dependencies` **{String|Array|Function}**: String, list or array of tasks.\n* `callback` **{Function}**: Function to be called when the task is executed. Task functions should either return a stream or call the callback to let [composer](https://github.com/doowb/composer) know when the task is finished.\n\n**Examples**\n\nRegister a task.\n\n```js\napp.task('default', function() {\n  // return the stream to signal \"done\"\n  return app.src('pages/*.hbs')\n    .pipe(app.dest('dist'));\n});\n```\n\nRegister a task with dependencies (other tasks to run before executing the task):\n\n```js\napp.task('site', ['styles'], function() {\n  return app.src('pages/*.hbs')\n    .pipe(app.dest('dist'));\n});\n\napp.task('default', ['site']);\n```\n\n**Get a task**\n\n```js\nconst task = app.task('site');\n```\n\n### .build\n\nRun a task or array of tasks.\n\n**Promise examples**\n\n```js\n// run the \"default\" task, if defined\napp.build();\napp.build('default');\n\n// run an array of tasks\napp.build(['foo', 'bar'])\n  .then(() =\u003e console.log('done!'))\n  .catch(console.error);\n```\n\n**Callback examples**\n\n```js\n// run the \"default\" task, if defined\napp.build(function(err, results) {\n  if (err) return console.error(err);\n  console.log(results);\n});\n\napp.build('default', function(err, results) {\n  if (err) return console.error(err);\n  console.log(results);\n});\n\napp.build(['foo', 'bar'], function(err, results) {\n  if (err) return console.error(err);\n  console.log(results);\n});\n```\n\n### .series\n\nCompose task or list of tasks into a single function that runs the tasks in series.\n\n**Params**\n\n* `tasks` **{String|Array|Function}**: List of tasks by name, function, or array of names/functions.\n* `returns` **{Function}**: Composed function that may take a callback function.\n\n**Example**\n\n```js\napp.task('foo', cb =\u003e {\n  console.log('this is foo');\n  cb();\n});\n\nconst build = app.series('foo', cb =\u003e {\n  console.log('this is bar');\n  cb();\n});\n\nbuild(function(err) {\n  if (err) return console.error(err);\n  console.log('finished');\n});\n//=\u003e this is foo\n//=\u003e this is bar\n//=\u003e finished\n```\n\n### .parallel\n\nCompose task or list of tasks into a single function that runs the tasks in parallel.\n\n**Params**\n\n* `tasks` **{String|Array|Function}**: List of tasks by name, function, or array of names/functions.\n* `returns` **{Function}**: Composed function that may take a callback function.\n\n**Example**\n\n```js\napp.task('foo', cb =\u003e {\n  setTimeout(function() {\n    console.log('this is foo');\n    cb();\n  }, 500);\n});\n\nconst build = app.parallel('foo', cb =\u003e {\n  console.log('this is bar');\n  cb();\n});\n\nbuild(function(err) {\n  if (err) return console.error(err);\n  console.log('finished');\n});\n//=\u003e this is bar\n//=\u003e this is foo\n//=\u003e finished\n```\n\n## Events\n\nThe following events are emitted by [composer](https://github.com/doowb/composer). See the composer docs for more details\n\n### on.task\n\nEmitted when a `task` is `register`, `starting` and `finished`.\n\n```js\napp.on('task', function(task) {\n  console.log(task.status);\n  //=\u003e 'register'\n});\n```\n\n### on.build\n\nEmitted when a `build` is `starting` and `finished`.\n\n```js\napp.on('build', function(build) {\n  console.log(build.status);\n  //=\u003e 'starting'\n});\n```\n\n## History\n\n### v2.0.0\n\n* Bumped [composer](https://github.com/doowb/composer) to v2.0.0.\n\n### v0.3.0\n\n* Bumped [composer](https://github.com/doowb/composer) to v0.11.0, so the `.watch` method is no longer included by default. To add `.watch`, use the [base-watch](https://github.com/node-base/base-watch) plugin.\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning 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:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nOther base plugins you might be interested in:\n\n* [base-cli](https://www.npmjs.com/package/base-cli): Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a… [more](https://github.com/node-base/base-cli) | [homepage](https://github.com/node-base/base-cli \"Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a few plugins, like 'base-store', 'base-options' and 'base-data'.\")\n* [base-generators](https://www.npmjs.com/package/base-generators): Adds project-generator support to your `base` application. | [homepage](https://github.com/node-base/base-generators \"Adds project-generator support to your `base` application.\")\n* [base-option](https://www.npmjs.com/package/base-option): Adds a few options methods to base, like `option`, `enable` and `disable`. See the readme… [more](https://github.com/node-base/base-option) | [homepage](https://github.com/node-base/base-option \"Adds a few options methods to base, like `option`, `enable` and `disable`. See the readme for the full API.\")\n* [base-plugins](https://www.npmjs.com/package/base-plugins): Adds 'smart plugin' support to your base application. | [homepage](https://github.com/node-base/base-plugins \"Adds 'smart plugin' support to your base application.\")\n* [base-store](https://www.npmjs.com/package/base-store): Plugin for getting and persisting config values with your base-methods application. Adds a 'store' object… [more](https://github.com/node-base/base-store) | [homepage](https://github.com/node-base/base-store \"Plugin for getting and persisting config values with your base-methods application. Adds a 'store' object that exposes all of the methods from the data-store library. Also now supports sub-stores!\")\n* [base](https://www.npmjs.com/package/base): Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks | [homepage](https://github.com/node-base/base \"Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks\")\n\n### Contributors\n\n| **Commits** | **Contributor** |  \n| --- | --- |  \n| 60 | [jonschlinkert](https://github.com/jonschlinkert) |  \n| 6  | [doowb](https://github.com/doowb) |  \n| 2  | [davequick](https://github.com/davequick) |  \n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on November 22, 2018._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbase-repos%2Fbase-task","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbase-repos%2Fbase-task","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbase-repos%2Fbase-task/lists"}