Skip to content

Commit dddfd22

Browse files
committed
fix: catch error if npm version missing
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.
1 parent ba4745c commit dddfd22

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ci/steps/publish-npm.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ main() {
139139
popd
140140
fi
141141

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

0 commit comments

Comments
 (0)