1 | import getTargetPath from './get-target-path.js';
|
2 | import maybeWrite from './maybe-write.js';
|
3 |
|
4 | export 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 | };
|