UNPKG

369 BJavaScriptView Raw
1import getTargetPath from './get-target-path.js';
2import maybeWrite from './maybe-write.js';
3
4export default async ({ buffer, path, target }) => {
5 const targetPath = getTargetPath({ buffer, path, target });
6
7 if (targetPath === path) throw new Error(`Refusing to overwrite ${path}`);
8
9 return { didChange: await maybeWrite({ buffer, targetPath }), targetPath };
10};