Skip to content

Commit

Permalink
fix: save tests only if modified
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed May 13, 2021
1 parent 6a25b98 commit b07b074
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions plugins/cc-cli/src/cli/save-test-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const saveTemplate = async <P extends TemplateOptions>(
);
return;
}
log('saving test', testFilePath, [115, 245, 184]);
const dataTemplate = await saveDataTemplate(options, configuration);

const content = await templateFn(
Expand All @@ -44,9 +43,15 @@ export const saveTemplate = async <P extends TemplateOptions>(
configuration,
);
if (content) {
if (!fs.existsSync(testFolder)) {
fs.mkdirSync(testFolder);
const existing =
fs.existsSync(testFilePath) && fs.readFileSync(testFilePath, 'utf8');
if (existing !== content) {
log('saving test', testFilePath, [115, 245, 184]);

if (!fs.existsSync(testFolder)) {
fs.mkdirSync(testFolder);
}
fs.writeFileSync(testFilePath, content, 'utf8');
}
fs.writeFileSync(testFilePath, content, 'utf8');
}
};

0 comments on commit b07b074

Please sign in to comment.