Skip to content

Commit

Permalink
feat: add support for npm-shrinkwrap.json (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
noreiller authored and bcoe committed Jun 4, 2017
1 parent 13eb9cd commit 86af7fc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ module.exports = function standardVersion (argv, done) {
var configsToUpdate = {}
function updateConfigs (args, newVersion) {
configsToUpdate[path.resolve(process.cwd(), './package.json')] = false
configsToUpdate[path.resolve(process.cwd(), './npm-shrinkwrap.json')] = false
configsToUpdate[path.resolve(process.cwd(), './bower.json')] = false
Object.keys(configsToUpdate).forEach(function (configPath) {
try {
Expand Down
28 changes: 26 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ function writeBowerJson (version, option) {
fs.writeFileSync('bower.json', JSON.stringify(bower), 'utf-8')
}

function writeNpmShrinkwrapJson (version, option) {
option = option || {}
var shrinkwrap = objectAssign(option, { version: version })
fs.writeFileSync('npm-shrinkwrap.json', JSON.stringify(shrinkwrap), 'utf-8')
}

function writeGitPreCommitHook () {
fs.writeFileSync('.git/hooks/pre-commit', '#!/bin/sh\necho "precommit ran"\nexit 1', 'utf-8')
fs.chmodSync('.git/hooks/pre-commit', '755')
Expand Down Expand Up @@ -520,13 +526,31 @@ describe('standard-version', function () {
writeBowerJson('1.0.0')
})

it('bumps verson # in bower.json', function (done) {
it('bumps version # in bower.json', function (done) {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
require('./index')({silent: true}, function (err) {
if (err) return done(err)
JSON.parse(fs.readFileSync('bower.json', 'utf-8')).version.should.equal('1.1.0')
getPackageVersion().should.equal('1.1.0')
done()
})
})
})

describe('npm-shrinkwrap.json support', function () {
beforeEach(function () {
writeNpmShrinkwrapJson('1.0.0')
})

it('bumps version # in npm-shrinkwrap.json', function (done) {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
require('./index')({silent: true}, function (err) {
if (err) return done(err)
JSON.parse(fs.readFileSync('package.json', 'utf-8')).version.should.equal('1.1.0')
JSON.parse(fs.readFileSync('npm-shrinkwrap.json', 'utf-8')).version.should.equal('1.1.0')
getPackageVersion().should.equal('1.1.0')
done()
})
Expand Down

0 comments on commit 86af7fc

Please sign in to comment.