@@ -5,6 +5,42 @@ const { chaiExec, expect } = require("../utils/chai");
55
66describe . skip ( "bump [files...]" , ( ) => {
77
8+ it ( "should update the package.json and package-lock.json by default" , ( ) => {
9+ files . create ( "package.json" , { version : "1.2.3" } ) ;
10+ files . create ( "package-lock.json" , { version : "1.2.3" } ) ;
11+
12+ let bump = chaiExec ( "major" ) ;
13+
14+ expect ( bump ) . to . have . stderr ( "" ) ;
15+ expect ( bump ) . to . have . exitCode ( 0 ) ;
16+
17+ bump . should . have . stdout (
18+ `${ check } Updated package.json to 2.0.0\n` +
19+ `${ check } Updated package-lock.json to 2.0.0\n`
20+ ) ;
21+
22+ expect ( files . json ( "package.json" ) . version ) . to . equal ( "2.0.0" ) ;
23+ expect ( files . json ( "package-lock.json" ) . version ) . to . equal ( "2.0.0" ) ;
24+ } ) ;
25+
26+ it ( "should not update package.json if package-lock.json is explicitly specified" , ( ) => {
27+ files . create ( "package.json" , { version : "1.2.3" } ) ;
28+ files . create ( "package-lock.json" , { version : "1.2.3" } ) ;
29+
30+ let bump = chaiExec ( "major" ) ;
31+
32+ expect ( bump ) . to . have . stderr ( "" ) ;
33+ expect ( bump ) . to . have . exitCode ( 0 ) ;
34+
35+ bump . should . have . stdout (
36+ `${ check } Updated package.json to 2.0.0\n` +
37+ `${ check } Updated package-lock.json to 2.0.0\n`
38+ ) ;
39+
40+ expect ( files . json ( "package.json" ) . version ) . to . equal ( "2.0.0" ) ;
41+ expect ( files . json ( "package-lock.json" ) . version ) . to . equal ( "2.0.0" ) ;
42+ } ) ;
43+
844 it ( "should replace the version number in non-manifest files" , ( ) => {
945 files . create ( "package.json" , { version : "1.2.3" } ) ;
1046 files . create ( "LICENSE" , fixtures . license ) ;
@@ -14,7 +50,7 @@ describe.skip("bump [files...]", () => {
1450 files . create ( "subdir/deep/script1.js" , fixtures . script1 ) ;
1551 files . create ( "subdir/deep/script2.js" , fixtures . script2 ) ;
1652
17- let bump = chaiExec ( "major LICENSE README.* *.js" ) ;
53+ let bump = chaiExec ( "major LICENSE README.* **/* .js" ) ;
1854
1955 expect ( bump ) . to . have . stderr ( "" ) ;
2056 expect ( bump ) . to . have . exitCode ( 0 ) ;
@@ -33,8 +69,27 @@ describe.skip("bump [files...]", () => {
3369 expect ( files . text ( "script1.js" ) ) . to . match ( / l e t v e r s i o n = " 2 .0 .0 " ; / ) ;
3470 } ) ;
3571
72+ it ( "should not replace other version fields in manifest files" , ( ) => {
73+ files . create ( "package.json" , { version : "1.2.3" , notTheVersion : "1.2.3" } ) ;
74+ files . create ( "package-lock.json" , { version : "1.2.3" , notTheVersion : "1.2.3" } ) ;
75+
76+ let bump = chaiExec ( "major" ) ;
77+
78+ expect ( bump ) . to . have . stderr ( "" ) ;
79+ expect ( bump ) . to . have . exitCode ( 0 ) ;
80+
81+ bump . should . have . stdout (
82+ `${ check } Updated package.json to 2.0.0\n` +
83+ `${ check } Updated package-lock.json to 2.0.0\n`
84+ ) ;
85+
86+ expect ( files . text ( "README.md" ) ) . to . match ( / v e r s i o n 5 .6 .7 a n d v 8 .9 .1 0 s h o u l d n o t b e c h a n g e d / ) ;
87+ expect ( files . text ( "script2.js" ) ) . to . match ( / v e r s i o n 3 .2 .1 a n d v 8 .9 .1 0 d o n ' t m a t c h t h e o l d v e r s i o n n u m b e r / ) ;
88+ } ) ;
89+
3690 it ( "should not replace other version numbers in non-manifest files" , ( ) => {
3791 files . create ( "package.json" , { version : "1.2.3" } ) ;
92+ files . create ( "package-lock.json" , { version : "1.2.3" } ) ;
3893 files . create ( "LICENSE" , fixtures . license ) ;
3994 files . create ( "README.md" , fixtures . readme ) ;
4095 files . create ( "script1.js" , fixtures . script1 ) ;
0 commit comments