@plugjs/plug
Version:
PlugJS Build System ===================
19 lines (18 loc) • 516 B
JavaScript
// plugs/edit.ts
import { readFile, writeFile } from "../fs.mjs";
import { install } from "../pipe.mjs";
install("edit", class Edit {
_callback;
constructor(...args) {
this._callback = args[0];
}
async pipe(files) {
for (const file of files.absolutePaths()) {
const data = await readFile(file, "utf-8");
const edited = await this._callback(data, file);
if (edited !== void 0) await writeFile(file, edited, "utf-8");
}
return files;
}
});
//# sourceMappingURL=edit.mjs.map