Skip to content

Commit

Permalink
Also publish user email in getGitInfo API
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Aug 8, 2023
1 parent 3ee4389 commit c2c64c2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions node-src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import checkPackageJson from './lib/checkPackageJson';
import { writeChromaticDiagnostics } from './lib/writeChromaticDiagnostics';
import invalidPackageJson from './ui/messages/errors/invalidPackageJson';
import noPackageJson from './ui/messages/errors/noPackageJson';
import { getBranch, getCommit, getSlug } from './git/git';
import { getBranch, getCommit, getSlug, getUserEmail } from './git/git';

/**
Make keys of `T` outside of `R` optional.
Expand Down Expand Up @@ -113,18 +113,20 @@ export async function runAll(ctx, options?: Options) {
}

export type GitInfo = {
userEmail: string;
branch: string;
commit: string;
slug: string;
};

export async function getGitInfo(): Promise<GitInfo> {
const userEmail = await getUserEmail();
const branch = await getBranch();
const { commit } = await getCommit();
const slug = await getSlug();

const [ownerName, repoName, ...rest] = slug ? slug.split('/') : [];
const isValidSlug = !!ownerName && !!repoName && !rest.length;

return { branch, commit, slug: isValidSlug ? slug : '' };
return { userEmail, branch, commit, slug: isValidSlug ? slug : '' };
}

0 comments on commit c2c64c2

Please sign in to comment.