File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22All notable changes will be documented in this file.
33` version-bump-prompt ` adheres to [ Semantic Versioning] ( http://semver.org/ ) .
44
5+ ## Unreleased
6+
7+ - Added ` --lock ` option to update the package-json.lock file
58
69## [ v4.0.0] ( https://github.com/BigstickCarpet/version-bump-prompt/tree/v4.0.0 ) (2017-11-15)
710
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ program
2323 . option ( '--push' , 'Push the Git commit' )
2424 . option ( '--all' , 'Commit/tag/push ALL pending files, not just the ones changed by bump' )
2525 . option ( '--grep <filespec...>' , 'Files and/or globs to do a text-replace of the old version number with the new one' )
26+ . option ( '--lock' , 'Also update the package-lock.json' )
2627 . on ( '--help' , ( ) => {
2728 console . log (
2829 ' Examples:\n' +
5253 options . commit = true ;
5354 }
5455
55- let manifests = api . manifests ( ) ;
56+ let manifests = api . manifests ( options . lock ) ;
5657 bumpManifests ( manifests , options )
5758 . then ( ( ) => {
5859 api . grep ( manifests , options ) ;
Original file line number Diff line number Diff line change @@ -27,8 +27,12 @@ module.exports = {
2727 *
2828 * @returns {string[] }
2929 */
30- function getManifests ( ) {
31- return [ 'package.json' , 'bower.json' , 'component.json' ] . filter ( ( manifest ) => {
30+ function getManifests ( withLockfile ) {
31+ let candidates = [ 'package.json' , 'bower.json' , 'component.json' ] ;
32+ if ( withLockfile ) {
33+ candidates . push ( 'package-lock.json' ) ;
34+ }
35+ return candidates . filter ( ( manifest ) => {
3236 let pkgPath = path . join ( cwd , manifest ) ;
3337 try {
3438 const pkg = require ( pkgPath ) ;
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ Options:
6363 --push Push the Git commit
6464 --all Commit/tag/push ALL pending files, not just the ones changed by bump
6565 --grep < filespec...> Files and/or globs to do a text-replace of the old version number with the new one
66+ --lock Update the package-lock.json file as well
6667
6768Examples:
6869
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const cli = require ( '../fixtures/cli' ) ;
4+ const files = require ( '../fixtures/files' ) ;
5+ const check = require ( '../fixtures/check' ) ;
6+ const chai = require ( 'chai' ) ;
7+
8+ chai . should ( ) ;
9+
10+ describe ( 'bump --lock' , ( ) => {
11+ it ( 'should not increment lock file by default' , ( ) => {
12+ files . create ( 'package-lock.json' , { version : '1.0.0' } ) ;
13+
14+ let output = cli . exec ( '--patch' ) ;
15+
16+ output . stderr . should . be . empty ;
17+ output . stdout . should . be . empty ;
18+ output . status . should . equal ( 0 ) ;
19+
20+ files . json ( 'package-lock.json' ) . should . deep . equal ( { version : '1.0.0' } ) ;
21+ } ) ;
22+
23+ it ( 'should increment version when lock option is provided' , ( ) => {
24+ files . create ( 'package-lock.json' , { version : '0.0.0' } ) ;
25+
26+ let output = cli . exec ( '--patch --lock' ) ;
27+
28+ output . stderr . should . be . empty ;
29+ output . status . should . equal ( 0 ) ;
30+
31+ output . lines . should . deep . equal ( [
32+ `${ check } Updated package-lock.json to 0.0.1` ,
33+ ] ) ;
34+
35+ files . json ( 'package-lock.json' ) . should . deep . equal ( { version : '0.0.1' } ) ;
36+ } ) ;
37+ } ) ;
You can’t perform that action at this time.
0 commit comments