cli: Add better error message if a patch failed

Signed-off-by: Marcus Eide <eide@spotify.com>
This commit is contained in:
Marcus Eide
2023-02-22 10:45:17 +01:00
committed by Philipp Hugenroth
parent c07c3b7364
commit 284810a0a1
@@ -32,6 +32,12 @@ export const patch = async (patchFile: string) => {
const targetFile = path.join(targetRoot, targetName);
const oldContent = await fs.readFile(targetFile, 'utf8');
const newContent = differ.applyPatch(oldContent, patchContent);
if (!newContent) {
throw new Error(
`Patch ${patchFile} was not applied correctly.
Did you change ${targetName} manually before running this command?`,
);
}
return await fs.writeFile(targetFile, newContent, 'utf8');
};