Skip to content

Commit

Permalink
only write git info if we have one
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo1212 committed Oct 26, 2023
1 parent 53e2731 commit cd41fd2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/gitInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ const main = () => {
gitCommitHash
};

const filePath = path.resolve('src', 'generatedGitInfo.json');
const fileContents = JSON.stringify(obj, null, 2);
if(gitBranch && gitCommitHash) {
const filePath = path.resolve('src', 'generatedGitInfo.json');
const fileContents = JSON.stringify(obj, null, 2);

fs.writeFileSync(filePath, fileContents);
console.log(`Wrote the following contents to ${filePath}\n${fileContents}`);
} else {
console.log('Skipped writing generatedGitInfo.json. Could not get git info')
}

fs.writeFileSync(filePath, fileContents);
console.log(`Wrote the following contents to ${filePath}\n${fileContents}`);

};

main();

0 comments on commit cd41fd2

Please sign in to comment.