Last active
December 28, 2018 10:29
-
-
Save rgabs/86dc9446ec3feb84423012a4511b718b to your computer and use it in GitHub Desktop.
A small script to compare the node package version of local project with the npm respository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This example does the following: | |
| # + Get the latest published version(live version) of react-native-modal-overlay. | |
| # + If the version specified in local package.json is: | |
| # 1. Less than the live version, it runs npm publish command to publish the newer verion. | |
| # 2. Greater or equal than the live version, then it logs a message saying: "Not publishing since version hasn't increased" | |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # | |
| # Use-case with CI/CD: | |
| # + We can configure CircleCI to publish a new version whenever a: | |
| # 1. New feature is merged to the master branch AND | |
| # 2. The package.json version is bumped. | |
| # + Currently being used for "react-native-modal-overlay" and here is the CircleCI config: https://github.com/rgabs/react-native-modal-overlay/blob/master/.circleci/config.yml | |
| LIVE_VERSION=`npm show react-native-modal-overlay version` | |
| PACKAGE_VERSION=$`node -p "require('./package.json').version"` | |
| function ver { printf "%03d%03d%03d%03d" $(echo "$1" | tr '.' ' '); } | |
| if [ $(ver "$PACKAGE_VERSION") -lt $(ver "$LIVE_VERSION") ]; then npm publish; else echo "Not publishing since version hasn't increased"; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment