From 284810a0a1c4e0d76cf98b7390bf2daaea6ff1c1 Mon Sep 17 00:00:00 2001 From: Marcus Eide Date: Wed, 22 Feb 2023 10:45:17 +0100 Subject: [PATCH] cli: Add better error message if a patch failed Signed-off-by: Marcus Eide --- packages/cli/src/commands/onboard/auth/patch.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/cli/src/commands/onboard/auth/patch.ts b/packages/cli/src/commands/onboard/auth/patch.ts index 2333275064..2ebca2aab2 100644 --- a/packages/cli/src/commands/onboard/auth/patch.ts +++ b/packages/cli/src/commands/onboard/auth/patch.ts @@ -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'); };