cogs
Version:
The fast file transform pipeline.
11 lines (7 loc) • 369 B
JavaScript
import getTargetPath from './get-target-path.js';
import maybeWrite from './maybe-write.js';
export default async ({ buffer, path, target }) => {
const targetPath = getTargetPath({ buffer, path, target });
if (targetPath === path) throw new Error(`Refusing to overwrite ${path}`);
return { didChange: await maybeWrite({ buffer, targetPath }), targetPath };
};