From 59337ef8b5186487204855ebf49d0ef849770076 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Tue, 27 Sep 2016 00:52:27 -0400 Subject: [PATCH] Update version format for usage with semver Tracking the version under one `-prerelease` channel allows other packages to depend on `^0.1.0-prerelease` for the most up to date version. Track the git sha for the release in package.json Reuse the json package needed for writing the sha to retrieve the package.json version field --- .travis.yml | 2 +- package.json | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 22dabee..ee7fd70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ after_script: # Authenticate NPM echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc # Set version to commit SHA - npm --no-git-tag-version version $(node -p -e "require('./package.json').version")-${TRAVIS_COMMIT:0:5} + npm --no-git-tag-version version $($(npm bin)/json -f package.json version)-prerelease.$(date +%s) npm publish # Publish to gh-pages as most recent committer git config --global user.email $(git log --pretty=format:"%ce" -n1) diff --git a/package.json b/package.json index 4726962..15402d2 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "main": "./dist.js", "scripts": { + "version": "./node_modules/.bin/json -f package.json -I -e \"this.repository.sha = '$(git log -n1 --pretty=format:%H)'\"", "prepublish": "make build", "start": "make serve", "test": "make test" @@ -24,6 +25,7 @@ "babel-preset-es2015": "6.9.0", "eslint": "2.7.0", "gh-pages": "0.11.0", + "json": "9.0.4", "json-loader": "0.5.4", "lodash.defaultsdeep": "4.6.0", "raw-loader": "0.5.1",