Skip to content

Commit

Permalink
Ensure we catch errors on projectMetadata
Browse files Browse the repository at this point in the history
This is not required information for the build, and as such failures
must not stop the process.
  • Loading branch information
jmhobbs committed Dec 11, 2024
1 parent 7131f46 commit 4b44b53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions node-src/git/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export async function getStorybookCreationDate(ctx: {
*/
export async function getNumberOfComitters() {
try {
return execGitCommandCountLines(`git shortlog -sn --all --since="6 months ago"`, {
return await execGitCommandCountLines(`git shortlog -sn --all --since="6 months ago"`, {
timeout: 5000,
});
} catch {
Expand All @@ -462,7 +462,7 @@ export async function getCommittedFileCount(nameMatches: string[], extensions: s
extensions.map((extension) => `"*${match}*.${extension}"`)
);

return execGitCommandCountLines(`git ls-files -- ${globs.join(' ')}`, {
return await execGitCommandCountLines(`git ls-files -- ${globs.join(' ')}`, {
timeout: 5000,
});
} catch {
Expand Down
18 changes: 11 additions & 7 deletions node-src/tasks/gitInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,17 @@ export const setGitInfo = async (ctx: Context, task: Task) => {
...commitAndBranchInfo,
};

ctx.projectMetadata = {
hasRouter: getHasRouter(ctx.packageJson),
creationDate: await getRepositoryCreationDate(),
storybookCreationDate: await getStorybookCreationDate(ctx),
numberOfCommitters: await getNumberOfComitters(),
numberOfAppFiles: await getCommittedFileCount(['page', 'screen'], ['js', 'jsx', 'ts', 'tsx']),
};
try {
ctx.projectMetadata = {
hasRouter: getHasRouter(ctx.packageJson),
creationDate: await getRepositoryCreationDate(),
storybookCreationDate: await getStorybookCreationDate(ctx),
numberOfCommitters: await getNumberOfComitters(),
numberOfAppFiles: await getCommittedFileCount(['page', 'screen'], ['js', 'jsx', 'ts', 'tsx']),
};
} catch (err) {
ctx.log.debug('Failed to gather project metadata', err);
}

if (isLocalBuild && !ctx.git.gitUserEmail) {
throw new Error(gitUserEmailNotFound());
Expand Down

0 comments on commit 4b44b53

Please sign in to comment.