11"use strict" ;
22
3- const { check, files } = require ( "../utils" ) ;
3+ const { check, files, fixtures } = require ( "../utils" ) ;
44const { chaiExec, expect } = require ( "../utils/chai" ) ;
55
66describe . skip ( "bump [files...]" , ( ) => {
77
88 it ( "should replace the version number in non-manifest files" , ( ) => {
99 files . create ( "package.json" , { version : "1.2.3" } ) ;
10- files . copy ( "LICENSE" ) ;
11- files . copy ( "README.md" ) ;
12- files . copy ( "script1.js" ) ;
13- files . copy ( "script2.js" ) ;
10+ files . create ( "LICENSE" , fixtures . license ) ;
11+ files . create ( "README.md" , fixtures . readme ) ;
12+ files . create ( "script1.js" , fixtures . script1 ) ;
13+ files . create ( "script2.js" , fixtures . script2 ) ;
14+ files . create ( "subdir/deep/script1.js" , fixtures . script1 ) ;
15+ files . create ( "subdir/deep/script2.js" , fixtures . script2 ) ;
1416
15- let bump = chaiExec ( "-- major --grep LICENSE README.* *.js" ) ;
17+ let bump = chaiExec ( "major LICENSE README.* *.js" ) ;
1618
1719 expect ( bump ) . to . have . stderr ( "" ) ;
1820 expect ( bump ) . to . have . exitCode ( 0 ) ;
1921
2022 bump . should . have . stdout (
21- `${ check } Updated package.json to 2.0.0\n` +
23+ `${ check } Updated LICENSE to 2.0.0\n` +
2224 `${ check } Updated README.md to 2.0.0\n` +
23- `${ check } Updated script1.js to 2.0.0\n` +
24- `${ check } Updated LICENSE to 2.0.0\n`
25+ `${ check } Updated script1.js to 2.0.0\n`
2526 ) ;
2627
2728 expect ( files . json ( "package.json" ) . version ) . to . equal ( "2.0.0" ) ;
@@ -34,12 +35,12 @@ describe.skip("bump [files...]", () => {
3435
3536 it ( "should not replace other version numbers in non-manifest files" , ( ) => {
3637 files . create ( "package.json" , { version : "1.2.3" } ) ;
37- files . copy ( "LICENSE" ) ;
38- files . copy ( "README.md" ) ;
39- files . copy ( "script1.js" ) ;
40- files . copy ( "script2.js" ) ;
38+ files . create ( "LICENSE" , fixtures . license ) ;
39+ files . create ( "README.md" , fixtures . readme ) ;
40+ files . create ( "script1.js" , fixtures . script1 ) ;
41+ files . create ( "script2.js" , fixtures . script2 ) ;
4142
42- let bump = chaiExec ( "-- major --grep LICENSE README.* *.js" ) ;
43+ let bump = chaiExec ( "major LICENSE README.* *.js" ) ;
4344
4445 expect ( bump ) . to . have . stderr ( "" ) ;
4546 expect ( bump ) . to . have . exitCode ( 0 ) ;
@@ -57,12 +58,56 @@ describe.skip("bump [files...]", () => {
5758
5859 it ( "should not not modify non-manifest files that don't contain the old version number" , ( ) => {
5960 files . create ( "package.json" , { version : "4.5.6" } ) ;
60- files . copy ( "LICENSE" ) ;
61- files . copy ( "README.md" ) ;
62- files . copy ( "script1.js" ) ;
63- files . copy ( "script2.js" ) ;
61+ files . create ( "LICENSE" , fixtures . license ) ;
62+ files . create ( "README.md" , fixtures . readme ) ;
63+ files . create ( "script1.js" , fixtures . script1 ) ;
64+ files . create ( "script2.js" , fixtures . script2 ) ;
65+
66+ let bump = chaiExec ( "major LICENSE README.* *.js" ) ;
67+
68+ expect ( bump ) . to . have . stderr ( "" ) ;
69+ expect ( bump ) . to . have . exitCode ( 0 ) ;
70+
71+ bump . should . have . stdout (
72+ `${ check } Updated package.json to 5.0.0\n`
73+ ) ;
74+
75+ expect ( files . json ( "package.json" ) . version ) . to . equal ( "5.0.0" ) ;
76+ expect ( files . text ( "LICENSE" ) ) . to . match ( / M y A p p v 1 .2 .3 C o p y r i g h t / ) ;
77+ 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 / ) ;
78+ expect ( files . text ( "README.md" ) ) . to . match ( / v e r s i o n 1 .2 .3 a n d v 1 .2 .3 s h o u l d b o t h g e t u p d a t e d / ) ;
79+ expect ( files . text ( "script1.js" ) ) . to . match ( / m a k e s u r e v 1 .2 .3 g e t s r e p l a c e d c o r r e c t l y / ) ;
80+ expect ( files . text ( "script1.js" ) ) . to . match ( / l e t v e r s i o n = " 1 .2 .3 " ; / ) ;
81+ expect ( files . text ( "script1.js" ) ) . to . match ( / l e t v e r s i o n = " 1 .2 .3 " ; / ) ;
82+ 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 / ) ;
83+ } ) ;
84+
85+ it ( "should error if an explicitly-specified file doesn't exist" , ( ) => {
86+ files . create ( "package.json" , { version : "4.5.6" } ) ;
87+
88+ let bump = chaiExec ( "major LICENSE README.* *.js" ) ;
89+
90+ expect ( bump ) . to . have . stderr ( "" ) ;
91+ expect ( bump ) . to . have . exitCode ( 0 ) ;
92+
93+ bump . should . have . stdout (
94+ `${ check } Updated package.json to 5.0.0\n`
95+ ) ;
96+
97+ expect ( files . json ( "package.json" ) . version ) . to . equal ( "5.0.0" ) ;
98+ expect ( files . text ( "LICENSE" ) ) . to . match ( / M y A p p v 1 .2 .3 C o p y r i g h t / ) ;
99+ 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 / ) ;
100+ expect ( files . text ( "README.md" ) ) . to . match ( / v e r s i o n 1 .2 .3 a n d v 1 .2 .3 s h o u l d b o t h g e t u p d a t e d / ) ;
101+ expect ( files . text ( "script1.js" ) ) . to . match ( / m a k e s u r e v 1 .2 .3 g e t s r e p l a c e d c o r r e c t l y / ) ;
102+ expect ( files . text ( "script1.js" ) ) . to . match ( / l e t v e r s i o n = " 1 .2 .3 " ; / ) ;
103+ expect ( files . text ( "script1.js" ) ) . to . match ( / l e t v e r s i o n = " 1 .2 .3 " ; / ) ;
104+ 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 / ) ;
105+ } ) ;
106+
107+ it ( "should error if a glob pattern doesn't match any files" , ( ) => {
108+ files . create ( "package.json" , { version : "4.5.6" } ) ;
64109
65- let bump = chaiExec ( "-- major --grep LICENSE README.* *.js" ) ;
110+ let bump = chaiExec ( "major README.* *.js" ) ;
66111
67112 expect ( bump ) . to . have . stderr ( "" ) ;
68113 expect ( bump ) . to . have . exitCode ( 0 ) ;
0 commit comments