33const { check, files, mocks, bump } = require ( "../utils" ) ;
44const { expect } = require ( "chai" ) ;
55
6- describe . skip ( "bump --commit" , ( ) => {
6+ describe ( "bump --commit" , ( ) => {
7+
8+ it ( "should not commit by default" , ( ) => {
9+ files . create ( "package.json" , { version : "1.0.0" } ) ;
10+
11+ let cli = bump ( "major" ) ;
12+
13+ expect ( cli ) . to . have . stderr ( "" ) ;
14+ expect ( cli ) . to . have . exitCode ( 0 ) ;
15+
16+ expect ( cli ) . to . have . stdout (
17+ `${ check } Updated package.json to 2.0.0\n`
18+ ) ;
19+
20+ let git = mocks . git ( ) ;
21+ expect ( git . length ) . to . equal ( 0 ) ;
22+ } ) ;
723
824 it ( "should commit the manifest file to git" , ( ) => {
925 files . create ( "package.json" , { version : "1.0.0" } ) ;
1026
11- let cli = bump ( "-- major --commit" ) ;
27+ let cli = bump ( "major --commit" ) ;
1228
1329 expect ( cli ) . to . have . stderr ( "" ) ;
1430 expect ( cli ) . to . have . exitCode ( 0 ) ;
@@ -20,37 +36,35 @@ describe.skip("bump --commit", () => {
2036
2137 let git = mocks . git ( ) ;
2238 expect ( git . length ) . to . equal ( 1 ) ;
23-
24- expect ( git [ 0 ] . cmd ) . to . equal ( 'git commit package.json -m "release v2.0.0"' ) ;
39+ expect ( git [ 0 ] ) . to . equal ( 'git commit --message "release v2.0.0" package.json' ) ;
2540 } ) ;
2641
2742 it ( "should commit multiple manifest files to git" , ( ) => {
2843 files . create ( "package.json" , { version : "1.0.0" } ) ;
2944 files . create ( "bower.json" , { version : "1.0.0" } ) ;
3045 files . create ( "component.json" , { version : "1.0.0" } ) ;
3146
32- let cli = bump ( "-- minor --commit" ) ;
47+ let cli = bump ( "minor *.json --commit" ) ;
3348
3449 expect ( cli ) . to . have . stderr ( "" ) ;
3550 expect ( cli ) . to . have . exitCode ( 0 ) ;
3651
3752 expect ( cli ) . to . have . stdout (
38- `${ check } Updated package.json to 1.1.0\n` +
3953 `${ check } Updated bower.json to 1.1.0\n` +
4054 `${ check } Updated component.json to 1.1.0\n` +
55+ `${ check } Updated package.json to 1.1.0\n` +
4156 `${ check } Git commit\n`
4257 ) ;
4358
4459 let git = mocks . git ( ) ;
4560 expect ( git . length ) . to . equal ( 1 ) ;
46-
47- expect ( git [ 0 ] . cmd ) . to . equal ( 'git commit package.json bower.json component.json -m "release v1.1.0"' ) ;
61+ expect ( git [ 0 ] ) . to . equal ( 'git commit --message "release v1.1.0" bower.json component.json package.json' ) ;
4862 } ) ;
4963
5064 it ( "should commit all files to git" , ( ) => {
5165 files . create ( "package.json" , { version : "1.0.0" } ) ;
5266
53- let cli = bump ( "-- minor --commit --all" ) ;
67+ let cli = bump ( "minor --commit --all" ) ;
5468
5569 expect ( cli ) . to . have . stderr ( "" ) ;
5670 expect ( cli ) . to . have . exitCode ( 0 ) ;
@@ -62,14 +76,13 @@ describe.skip("bump --commit", () => {
6276
6377 let git = mocks . git ( ) ;
6478 expect ( git . length ) . to . equal ( 1 ) ;
65-
66- expect ( git [ 0 ] . cmd ) . to . equal ( 'git commit -a -m "release v1.1.0"' ) ;
79+ expect ( git [ 0 ] ) . to . equal ( 'git commit --all --message "release v1.1.0"' ) ;
6780 } ) ;
6881
6982 it ( "should commit without running pre-commit hooks" , ( ) => {
7083 files . create ( "package.json" , { version : "1.0.0" } ) ;
7184
72- let cli = bump ( "-- minor --commit --all --no-verify" ) ;
85+ let cli = bump ( "minor --commit --all --no-verify" ) ;
7386
7487 expect ( cli . stderr ) . to . be . empty ;
7588 expect ( cli ) . to . have . exitCode ( 0 ) ;
@@ -81,14 +94,49 @@ describe.skip("bump --commit", () => {
8194
8295 let git = mocks . git ( ) ;
8396 expect ( git . length ) . to . equal ( 1 ) ;
97+ expect ( git [ 0 ] ) . to . equal ( 'git commit --all --no-verify --message "release v1.1.0"' ) ;
98+ } ) ;
99+
100+ it ( "should append the version number to the commit message" , ( ) => {
101+ files . create ( "package.json" , { version : "1.0.0" } ) ;
102+
103+ let cli = bump ( 'patch --all --commit "this is release v"' ) ;
104+
105+ expect ( cli ) . to . have . stderr ( "" ) ;
106+ expect ( cli ) . to . have . exitCode ( 0 ) ;
107+
108+ expect ( cli ) . to . have . stdout (
109+ `${ check } Updated package.json to 1.0.1\n` +
110+ `${ check } Git commit\n`
111+ ) ;
112+
113+ let git = mocks . git ( ) ;
114+ expect ( git . length ) . to . equal ( 1 ) ;
115+ expect ( git [ 0 ] ) . to . equal ( 'git commit --all --message "this is release v1.0.1"' ) ;
116+ } ) ;
117+
118+ it ( "should replace version number placeholders in the commit message" , ( ) => {
119+ files . create ( "package.json" , { version : "1.0.0" } ) ;
84120
85- expect ( git [ 0 ] . cmd ) . to . equal ( 'git commit --no-verify -a -m "release v1.1.0"' ) ;
121+ let cli = bump ( 'patch --all --commit "Releasing v%s. This is release v%s."' ) ;
122+
123+ expect ( cli ) . to . have . stderr ( "" ) ;
124+ expect ( cli ) . to . have . exitCode ( 0 ) ;
125+
126+ expect ( cli ) . to . have . stdout (
127+ `${ check } Updated package.json to 1.0.1\n` +
128+ `${ check } Git commit\n`
129+ ) ;
130+
131+ let git = mocks . git ( ) ;
132+ expect ( git . length ) . to . equal ( 1 ) ;
133+ expect ( git [ 0 ] ) . to . equal ( 'git commit --all --message "Releasing v1.0.1. This is release v1.0.1."' ) ;
86134 } ) ;
87135
88- it ( "should commit the manifest files to git with a message" , ( ) => {
136+ it ( "should accept an empty commit message" , ( ) => {
89137 files . create ( "package.json" , { version : "1.0.0" } ) ;
90138
91- let cli = bump ( "-- patch --all --commit my-message" ) ;
139+ let cli = bump ( [ " patch" , " --all" , " --commit" , "" ] ) ;
92140
93141 expect ( cli ) . to . have . stderr ( "" ) ;
94142 expect ( cli ) . to . have . exitCode ( 0 ) ;
@@ -101,7 +149,7 @@ describe.skip("bump --commit", () => {
101149 let git = mocks . git ( ) ;
102150 expect ( git . length ) . to . equal ( 1 ) ;
103151
104- expect ( git [ 0 ] . cmd ) . to . equal ( ' git commit -a -m "v1 .0.1 my-message"' ) ;
152+ expect ( git [ 0 ] ) . to . equal ( " git commit --all --message 1 .0.1" ) ;
105153 } ) ;
106154
107155} ) ;
0 commit comments