mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-21 05:20:24 +08:00
* Created tslint.json for undertaker * Updated to 1.1 version. * Fixed contributor link. * flatten contributes' list * Added param array of task in series and parallel methods. * Updated jsdoc comments. * Extended EventEmitter in Undertaker class. Added test for EventEmitter.
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
/// <reference types="node" />
|
|
import * as fs from "fs";
|
|
import * as Undertaker from "undertaker";
|
|
import * as Registry from "undertaker-registry";
|
|
|
|
const taker = new Undertaker();
|
|
|
|
taker.task("task1", (cb: () => void) => {
|
|
// do things
|
|
cb(); // when everything is done
|
|
});
|
|
|
|
taker.task("task2", () => {
|
|
return fs.createReadStream("./myFile.js")
|
|
.pipe(fs.createWriteStream("./myFile.copy.js"));
|
|
});
|
|
|
|
taker.task("task3", () => {
|
|
return new Promise((resolve, reject) => {
|
|
// do things
|
|
resolve(); // when everything is done
|
|
});
|
|
});
|
|
|
|
taker.task("combined", taker.series("task1", "task2"));
|
|
|
|
taker.task("all", taker.parallel("combined", "task3"));
|
|
|
|
taker.task("all-parallel-array", taker.parallel(["combined", "task3"]));
|
|
|
|
taker.task("all-series-array", taker.series(["combined", "task3"]));
|
|
|
|
const registry = new Registry();
|
|
const CommonRegistry = (options: { buildDir: string }): Registry => {
|
|
return registry;
|
|
};
|
|
|
|
const taker2 = new Undertaker(CommonRegistry({ buildDir: "/dist" }));
|
|
|
|
taker2.task("build", taker2.series("clean", (cb: () => void) => {
|
|
// do things
|
|
cb();
|
|
}));
|
|
|
|
taker2.addListener("event", () => {
|
|
// Checking for extended EventEmitter
|
|
});
|