Skip to content

Commit

Permalink
fix: improve github client missing env var error
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed Jun 2, 2023
1 parent e82618b commit ce4b352
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -16,5 +16,5 @@
}
},
"ignoreChanges": ["**/__fixtures__/**", "**/__tests__/**", "**/*.md"],
"version": "7.0.0-alpha.0"
"version": "7.0.0-alpha.5"
}
10 changes: 7 additions & 3 deletions libs/core/src/lib/scm-clients/github/create-github-client.ts
@@ -1,6 +1,7 @@
import log from "npmlog";
import { Octokit } from "@octokit/rest";
import parseGitUrl from "git-url-parse";
import log from "npmlog";
import { ValidationError } from "../../validation-error";

// eslint-disable-next-line @typescript-eslint/no-var-requires
const childProcess = require("@lerna/child-process");
Expand All @@ -14,7 +15,10 @@ export function createGitHubClient(): Octokit {
const { GH_TOKEN, GHE_API_URL, GHE_VERSION } = process.env;

if (!GH_TOKEN) {
throw new Error("A GH_TOKEN environment variable is required.");
throw new ValidationError(
"",
`A GH_TOKEN environment variable is required when "createRelease" is set to "github"`
);
}

if (GHE_VERSION) {
Expand Down Expand Up @@ -52,7 +56,7 @@ export function parseGitRepo(remote = "origin", opts?: any) {
const url = childProcess.execSync("git", args, opts);

if (!url) {
throw new Error(`Git remote URL could not be found using "${remote}".`);
throw new ValidationError("", `Git remote URL could not be found using "${remote}".`);
}

return parseGitUrl(url);
Expand Down

0 comments on commit ce4b352

Please sign in to comment.