Skip to content

Commit

Permalink
[PR Feedback] Cleaned up argument logic
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeShirley committed Sep 6, 2024
1 parent 499755f commit 78e9079
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/verify-vsce-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@ const SemanticReleaseError = require('@semantic-release/error');
const execa = require('execa');

module.exports = async (logger, cwd) => {
if (!process.env.VSCE_PAT && !process.env.VSCE_AZURE_CREDENTIAL) {
const patAuth = 'VSCE_PAT' in process.env && process.env.VSCE_PAT;
const vsceAuth =
'VSCE_AZURE_CREDENTIAL' in process.env && process.env.VSCE_AZURE_CREDENTIAL;

if (!patAuth && !vsceAuth) {
throw new SemanticReleaseError(
'Neither vsce personal access token (`VSCE_PAT` environment variable) or Azure Credentials flag (`VSCE_AZURE_CREDENTIAL` environment variable) specified.',
'EVSCEAUTHNOTPROVIDED',
);
}

if (process.env.VSCE_PAT && process.env.VSCE_AZURE_CREDENTIAL) {
if (patAuth && vsceAuth) {
throw new SemanticReleaseError(
'Both vsce personal access token (`VSCE_PAT` environment variable) or Azure Credentials flag (`VSCE_AZURE_CREDENTIAL` environment variable) specified. Please use only one.',
'EVSCEDUPLICATEAUTHPROVIDED',
);
}

const vsceArgs = ['verify-pat'];
if (process.env.VSCE_AZURE_CREDENTIAL) {
if (vsceAuth) {
vsceArgs.push('--azure-credential');
}

Expand Down

0 comments on commit 78e9079

Please sign in to comment.