Skip to content

Commit

Permalink
#72 Add bump script
Browse files Browse the repository at this point in the history
  • Loading branch information
co2-git committed Apr 29, 2018
1 parent ad68037 commit b46bab7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"scripts": {
"babel": "babel --out-dir dist/ app/",
"branch": "bash scripts/branch.sh v$npm_package_version",
"bump": "bash scripts/bump.sh",
"eslint": "eslint app --fix",
"fix": "yarn test && yarn pr",
"flow": "flow",
Expand Down
15 changes: 15 additions & 0 deletions scripts/bump.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const [,, action = 'bump', pkg, version] = process.argv;

const info = JSON.parse(pkg);

if (action === 'bump') {
const [api, major, minor] = info.version.split(/\./);
const newVersion = `${api}.${major}.${Number(minor) + 1}`;
console.log(newVersion);
} else if (action === 'rewrite') {
info.version = version;
const rw = JSON.stringify(info, null, 2);
console.log(rw)
} else {
throw new Error('Unknown action');
}
14 changes: 14 additions & 0 deletions scripts/bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /bin/bash

JSON="$(cat ./package.json)"
VERSION="$1"

if [ -z "$VERSION" ]; then
VERSION="$(node ./scripts/bump bump "$JSON")"
echo $VERSION
fi

# git co master &&
# git pull &&
# git co -b v$VERSION &&
node scripts/bump rewrite "$JSON" $VERSION > ./package.json

0 comments on commit b46bab7

Please sign in to comment.