Skip to content

Commit

Permalink
Fail persistence when token is missing (even if no files are persisted)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Nov 15, 2024
1 parent 3a55f1b commit e6e11ae
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Persist.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class Persist {
}

setTarget(target) {
// Must have a token to use this feature
if(!process.env.GITHUB_TOKEN) {
throw new Error("Missing GITHUB_TOKEN environment variable.");
}

let { type, username, repository, branch } = Persist.parseTarget(target);
if(!Persist.SUPPORTED_TYPES.includes(type)) {
throw new Error("Invalid persist type: " + type);
Expand All @@ -61,10 +66,6 @@ class Persist {
}

get publisher() {
if(!process.env.GITHUB_TOKEN) {
throw new Error("Missing GITHUB_TOKEN environment variable.");
}

if(!this.canPersist()) {
throw new Error("Missing Persist target. Have you called setTarget()?");
}
Expand Down

0 comments on commit e6e11ae

Please sign in to comment.