@plugjs/plug
Version:
PlugJS Build System ===================
22 lines • 852 B
JavaScript
import { readFile, writeFile } from "../fs.js";
import { install } from "../pipe.js";
/* ========================================================================== *
* INSTALLATION / IMPLEMENTATION *
* ========================================================================== */
/** Edits the content of all files in a pipeline. */
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 !== undefined)
await writeFile(file, edited, 'utf-8');
}
return files;
}
});
//# sourceMappingURL=edit.js.map