Skip to content

jerboa88/NoBS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NoBS - Node Build Script

Project type Language Repository size Project license

A dead simple build task runner for Node.js.

Automate your build process by scheduling build tasks to be run either sequentially or concurrently using a simple array-based config object.


This is an experimental project and there are likely a lot of bugs to be ironed out. I would recommend Gulp as a more powerful, fleshed out alternative

Installation

Install with npm install git+https://github.com/jerboa88/NoBS.git for the latest version. The project is not on NPM at this time.

Usage

  1. Import the module with:
const NoBS = require('NoBS');
  1. Create an array of tasks:
const taskList = [
	[taskA1, taskA2],
	[taskB1],
	[taskC1, taskC2, taskC3]
];

Tasks are simply functions which return a promise. Tasks are contained in stages, which are the sub-arrays shown here. Every task in a stage will be started at the same time, and once all tasks in a stage are complete, the next stage will start. Note that this cannot be nested any further.

  1. (Optional) Define additional options:
const options = {
	taskSuccessCallback: taskSuccessCallback,
	taskErrorCallback: taskErrorCallback,
	debug: true
}

Any of these properties can be left out if not required.

taskSuccessCallback and taskErrorCallback are callback functions that are fired each time a task completes or fails, respectively. They should each accept three arguments:

  • taskName: The function name of a task
  • result/error: The value passed to resolve() or reject() when a task finishes. Since you write the task functions, this can be whatever you want
  • stageHasError: Whether an error has been encountered while running any tasks in this stage. We will wait for all tasks in a stage to complete even if there is an error, so this can be used to filter out duplicate error messages, for example

debug controls whether debug messages are printed to the console.

  1. Create a NoBS object with:
const noBS = new NoBS(taskList, options);

Note that options is not required here.

  1. Run tasks with NoBS:
noBS.run()
	.then(result => console.log('Done'))
	.catch(error => console.error(`Error: ${error}`));

Please see test.js for a complete example.

Contributing

This is an experimental project but input is welcome :). SemVer is used for versioning.

License

This project is licensed under the MIT License. See LICENSE for details.