@plugjs/plug
Version:
PlugJS Build System ===================
71 lines (69 loc) • 2.48 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// plugs/build.ts
var build_exports = {};
__export(build_exports, {
RunBuild: () => RunBuild,
RunBuildInternal: () => RunBuildInternal
});
module.exports = __toCommonJS(build_exports);
var import_build = require("../build.cjs");
var import_fork = require("../fork.cjs");
var import_colors = require("../logging/colors.cjs");
var import_paths = require("../paths.cjs");
var RunBuildInternal = class {
constructor(_tasks, _props, _options) {
this._tasks = _tasks;
this._props = _props;
this._options = _options;
}
async pipe(files, context) {
const tasks = this._tasks.length === 0 ? ["default"] : this._tasks;
const cwd = this._options.cwd || process.cwd();
for (const file of files.absolutePaths()) {
let maybeBuild = await import(file);
while (maybeBuild) {
if ((0, import_build.isBuild)(maybeBuild)) break;
maybeBuild = maybeBuild.default;
}
if (!(0, import_build.isBuild)(maybeBuild)) {
context.log.fail(`File ${(0, import_colors.$p)(file)} did not export a proper build`);
} else {
const dir = process.cwd();
try {
process.chdir(cwd);
await (0, import_build.invokeTasks)(maybeBuild, tasks, this._props);
} finally {
process.chdir(dir);
}
}
}
}
};
var RunBuild = class extends import_fork.ForkingPlug {
constructor(tasks, props, options) {
super((0, import_paths.requireFilename)(__filename), [tasks, props, options], RunBuildInternal.name);
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
RunBuild,
RunBuildInternal
});
//# sourceMappingURL=build.cjs.map