Skip to content

Commit

Permalink
chore: Add pkgset script (#19)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Roberts <code@rbrts.uk>
  • Loading branch information
mttrbrts authored Oct 25, 2018
1 parent 486fad6 commit fd9cc38
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ if [[ "${BUILD_RELEASE}" = "stable" ]]; then
git clean -d -f

# Bump the version number.
npm run pkgbump
npm run pkgset
export NEW_VERSION=$(node -e "console.log(require('${DIR}/package.json').version)")

# Add the version number changes and push them to Git.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"mocha": "mocha --recursive -t 10000",
"nyc": "nyc mocha --recursive -t 10000",
"pkgbump": "node ./scripts/pkgbump.js",
"pkgstamp": "node ./scripts/pkgstamp.js"
"pkgstamp": "node ./scripts/pkgstamp.js",
"pkgset": "node ./scripts/pkgset.js"
},
"repository": {
"type": "git",
Expand Down
27 changes: 27 additions & 0 deletions scripts/pkgset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env node
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

const fs = require('fs');
const path = require('path');
const semver = require('semver');

const packageDirectory = path.resolve('.');
const packageConfigFile = path.resolve(packageDirectory, 'package.json');
const packageConfig = require(packageConfigFile);
const targetVersion = semver.clean(process.argv[2]);
packageConfig.version = targetVersion;
fs.writeFileSync(packageConfigFile, JSON.stringify(packageConfig, null, 2), 'utf8');

0 comments on commit fd9cc38

Please sign in to comment.