fuse-box
Version:
Fuse-Box a bundler that does it right
41 lines (39 loc) • 1.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const realm_utils_1 = require("realm-utils");
class BundleRunner {
constructor(fuse) {
this.fuse = fuse;
this.topTasks = [];
this.bundles = [];
this.bottomTasks = [];
}
top(fn) {
this.topTasks.push(fn);
}
bottom(fn) {
this.bottomTasks.push(fn);
}
bundle(bundle) {
this.bundles.push(bundle);
}
executeTop() {
return Promise.all(this.topTasks.map(fn => fn()));
}
executeBottom() {
return Promise.all(this.bottomTasks.map(fn => fn()));
}
executeBundles(runType) {
if (runType === "waterall ") {
return realm_utils_1.each(this.bundles, bundle => bundle.exec());
}
return Promise.all(this.bundles.map(bundle => bundle.exec()));
}
run(opts = { runType: "waterall" }) {
return this.executeTop()
.then(() => this.executeBundles(opts.runType))
.then(() => this.executeBottom());
}
}
exports.BundleRunner = BundleRunner;
//# sourceMappingURL=BundleRunner.js.map