Skip to content

Commit

Permalink
fix: handle errors when git repository is invalid, set strict mode in…
Browse files Browse the repository at this point in the history
… tsconfig
  • Loading branch information
rafalmaciejewski committed Aug 12, 2022
1 parent ca4858d commit db8cb5b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/get-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export async function getContext(
git.getConfig('user.name'),
git.getConfig('user.email'),
]);
if (!userName || !userEmail) {
throw new Error('user.name or user.email git options are not configured');
}
const repository = getRepositoryFromRemotes(remotes, provider);
return {
linkPattern: pattern ?? linkPatternsByProvider[repository.type],
Expand Down
3 changes: 3 additions & 0 deletions src/get-repository-from-remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export function getRepositoryFromRemotes(
initialProvider: Provider = 'unknown',
): Repository {
const origin = remotes.find((remote) => remote.name === 'origin');
if (!origin) {
throw new Error('origin not found');
}
const ref = origin.refs.fetch ?? origin.refs.push;

const [protocol, repositoryUrl, org, project] = extract(ref);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"outDir": "./lib",
"baseUrl": "./src",
"declaration": true,
"noImplicitAny": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
Expand Down

0 comments on commit db8cb5b

Please sign in to comment.