Created
December 15, 2016 11:11
-
-
Save marcbachmann/c659b5289b11cab4ba852f9287801766 to your computer and use it in GitHub Desktop.
Semantic release - change release & publishConfig in package.json
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
var fs = require('fs') | |
var jp = require('jsonpointer') | |
var tag = process.env.TAG | |
var branch = process.env.BRANCH | |
if (!tag || !branch) { | |
console.error([ | |
'Error: BRANCH and TAG environment variables are required.', | |
'---', | |
'Usage:', | |
"TAG='maintenance-v9.4.4' BRANCH='maintenance-v9.4.4' ./release-for-npm.js" | |
].join('\n')) | |
process.exit(1) | |
} | |
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8')) | |
jp.set(pkg, '/release/branch', branch) | |
jp.set(pkg, '/publishConfig/tag', tag) | |
var changes = { | |
release: {branch: branch}, | |
publishConfig: {tag: tag} | |
} | |
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n') | |
console.log('changes:\n', JSON.stringify(changes, null, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment