Skip to content

Commit

Permalink
chore: add catch error for verifyWorkingTree (#2859)
Browse files Browse the repository at this point in the history
  • Loading branch information
fireairforce committed Dec 13, 2022
1 parent 027d943 commit b028984
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions commands/publish/index.js
Expand Up @@ -297,7 +297,19 @@ class PublishCommand extends Command {
let chain = Promise.resolve();

// attempting to publish a tagged release with local changes is not allowed
chain = chain.then(() => this.verifyWorkingTreeClean());
chain = chain
.then(() => this.verifyWorkingTreeClean())
.catch((err) => {
// an execa error is thrown when git suffers a fatal error (such as no git repository present)
if (err.failed && /git describe/.test(err.command)) {
// (we tried)
this.logger.silly("EWORKINGTREE", err.message);
this.logger.notice("FYI", "Unable to verify working tree, proceed at your own risk");
} else {
// validation errors should be preserved
throw err;
}
});

chain = chain.then(() => getCurrentTags(this.execOpts, matchingPattern));
chain = chain.then((taggedPackageNames) => {
Expand Down Expand Up @@ -382,7 +394,19 @@ class PublishCommand extends Command {
let chain = Promise.resolve();

// attempting to publish a canary release with local changes is not allowed
chain = chain.then(() => this.verifyWorkingTreeClean());
chain = chain
.then(() => this.verifyWorkingTreeClean())
.catch((err) => {
// an execa error is thrown when git suffers a fatal error (such as no git repository present)
if (err.failed && /git describe/.test(err.command)) {
// (we tried)
this.logger.silly("EWORKINGTREE", err.message);
this.logger.notice("FYI", "Unable to verify working tree, proceed at your own risk");
} else {
// validation errors should be preserved
throw err;
}
});

// find changed packages since last release, if any
chain = chain.then(() =>
Expand Down

0 comments on commit b028984

Please sign in to comment.