diff --git a/packages/grafana-toolkit/src/cli/tasks/plugin.build.ts b/packages/grafana-toolkit/src/cli/tasks/plugin.build.ts index eb2d5b16b8e..e5dcaa12d1b 100644 --- a/packages/grafana-toolkit/src/cli/tasks/plugin.build.ts +++ b/packages/grafana-toolkit/src/cli/tasks/plugin.build.ts @@ -87,22 +87,23 @@ export const prettierCheckPlugin = useSpinner('Prettier check', async ( } }) .then(newContents => { - if (fix && newContents && newContents.length > 10) { - return writeFile(path, newContents) - .then(() => { - console.log(`Fixed: ${path}`); - return true; - }) - .catch(error => { - console.log(`Error fixing ${path}`, error); - return false; - }); + if (newContents === undefined) { + return true; // Nothing to fix } else if (fix) { + if (newContents.length > 10) { + return writeFile(path, newContents) + .then(() => { + console.log(`Fixed: ${path}`); + return true; + }) + .catch(error => { + console.log(`Error fixing ${path}`, error); + return false; + }); + } console.log(`No automatic fix for: ${path}`); - return false; - } else { - return false; } + return false; }) .then(success => ({ path, success })) );