maestra

1.0.0 • Public • Published

Maestra

Get ready for an encore with this reprise to Octavia's concerto of mayhem.

Another task manager & runner based on dependencies.

Table of Contents

Installation

npm install maestra --save

Usage

const delay = require("delay");
const Maestra = require("maestra");
 
// Create a new maestra
const maestra = new Maestra();
 
// Add a task
maestra.add("lorem", [], () => {});
 
// Add a task depending of `lorem`
maestra.add("ipsum", ["lorem"], () => {});
 
// Add an task depending of `lorem`
maestra.add("dolor", ["lorem"], () => delay(3000));
 
// Add a task depending of `ipsum` & `dolor`
maestra.add("sit", ["ipsum", "dolor"], () => Promise.reject(new Error("Oof!")));
 
// Called when a task started
maestra.on("task-started", task => {
  console.log("[%s] started", task.name);
});
 
// Called when a task completed
maestra.on("task-completed", task => {
  console.log("[%s] completed", task.name);
});
 
// Called when a task failed
maestra.on("task-failed", (task, error) => {
  console.log("[%s] failed", task.name, error);
});
 
// Run the `ipsum` task and its dependencies
maestra.run(["ipsum"]).then(report => {
  // Report all tasks
  console.log('Task "ipsum" complete', report);
 
  // Reset the `ipsum` task
  maestra.reset(["ipsum"]);
 
  // Run all tasks
  maestra.run().catch(error => {
    // Reject if the report contains errors
    console.log("Oof!", error);
  });
});

Author

Alexandre Breteau - @0xSeldszar

License

MIT © Alexandre Breteau

Package Sidebar

Install

npm i maestra

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

13.2 kB

Total Files

9

Last publish

Collaborators

  • seldszar