Skip to content

Commit

Permalink
fix: catch error if npm version missing
Browse files Browse the repository at this point in the history
npm changed the way the `npm view` command handles missing versions.
Before it exited with a non-error. Now it errors.

Ref: npm/cli#5035

This modifies the script logic to handle those new changes.
  • Loading branch information
jsjoeio committed Aug 23, 2022
1 parent ba4745c commit dddfd22
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ci/steps/publish-npm.sh
Expand Up @@ -139,13 +139,13 @@ main() {
popd
fi

# NOTE@jsjoeio
# We need to make sure we haven't already published the version.
# This is because npm view won't exit with non-zero so we have
# to check the output.
# If we get error, continue with script because we want to publish
# If version is valid, we check if we're publishing the same one
local hasVersion
hasVersion=$(npm view "code-server@$NPM_VERSION" version)
if [[ $hasVersion == "$NPM_VERSION" ]]; then
echo "$NPM_VERSION is already published"
if hasVersion=$(npm view "$PACKAGE_NAME@$NPM_VERSION" version 2> /dev/null) && [[ $hasVersion == "$NPM_VERSION" ]]; then
echo "$NPM_VERSION is already published under $PACKAGE_NAME"
return
fi

Expand Down

0 comments on commit dddfd22

Please sign in to comment.