3
3
const { check, files, mocks, bump } = require ( "../utils" ) ;
4
4
const { expect } = require ( "chai" ) ;
5
5
6
- describe . skip ( "npm version hooks" , ( ) => {
6
+ describe ( "npm version hooks" , ( ) => {
7
+
7
8
if ( process . platform === "win32" && process . env . CI ) {
8
- // Spawning NPM fails on Windows due to a bug in NYC (actually in its dependency, spawn-wrap)
9
- // So skip these tests until this bug is fixed: https://github.com/istanbuljs/nyc/issues/760
9
+ // Spawning NPM fails on Windows due to a bug in NYC
10
10
return ;
11
11
}
12
12
@@ -18,19 +18,20 @@ describe.skip("npm version hooks", () => {
18
18
} ,
19
19
} ) ;
20
20
21
- let cli = bump ( "-- major" ) ;
21
+ let cli = bump ( "major" ) ;
22
22
23
23
expect ( cli ) . to . have . stderr ( "" ) ;
24
24
expect ( cli ) . to . have . exitCode ( 0 ) ;
25
25
26
26
expect ( cli ) . to . have . stdout (
27
+ `${ check } Npm run preversion\n` +
27
28
`${ check } Updated package.json to 2.0.0\n`
28
29
) ;
29
30
30
- let npm = mocks . npm ( ) ;
31
+ let npm = mocks . npmDetails ( ) ;
31
32
expect ( npm . length ) . to . equal ( 1 ) ;
32
33
33
- expect ( npm [ 0 ] . cmd ) . to . equal ( "npm run preversion" ) ;
34
+ expect ( npm [ 0 ] . cmd ) . to . equal ( "npm run preversion --silent " ) ;
34
35
expect ( npm [ 0 ] . version ) . to . equal ( "1.0.0" ) ;
35
36
} ) ;
36
37
@@ -42,19 +43,20 @@ describe.skip("npm version hooks", () => {
42
43
} ,
43
44
} ) ;
44
45
45
- let cli = bump ( "-- major" ) ;
46
+ let cli = bump ( "major" ) ;
46
47
47
48
expect ( cli ) . to . have . stderr ( "" ) ;
48
49
expect ( cli ) . to . have . exitCode ( 0 ) ;
49
50
50
51
expect ( cli ) . to . have . stdout (
51
- `${ check } Updated package.json to 2.0.0\n`
52
+ `${ check } Updated package.json to 2.0.0\n` +
53
+ `${ check } Npm run version\n`
52
54
) ;
53
55
54
- let npm = mocks . npm ( ) ;
56
+ let npm = mocks . npmDetails ( ) ;
55
57
expect ( npm . length ) . to . equal ( 1 ) ;
56
58
57
- expect ( npm [ 0 ] . cmd ) . to . equal ( "npm run version" ) ;
59
+ expect ( npm [ 0 ] . cmd ) . to . equal ( "npm run version --silent " ) ;
58
60
expect ( npm [ 0 ] . version ) . to . equal ( "2.0.0" ) ;
59
61
} ) ;
60
62
@@ -66,19 +68,20 @@ describe.skip("npm version hooks", () => {
66
68
} ,
67
69
} ) ;
68
70
69
- let cli = bump ( "-- major" ) ;
71
+ let cli = bump ( "major" ) ;
70
72
71
73
expect ( cli ) . to . have . stderr ( "" ) ;
72
74
expect ( cli ) . to . have . exitCode ( 0 ) ;
73
75
74
76
expect ( cli ) . to . have . stdout (
75
- `${ check } Updated package.json to 2.0.0\n`
77
+ `${ check } Updated package.json to 2.0.0\n` +
78
+ `${ check } Npm run postversion\n`
76
79
) ;
77
80
78
- let npm = mocks . npm ( ) ;
81
+ let npm = mocks . npmDetails ( ) ;
79
82
expect ( npm . length ) . to . equal ( 1 ) ;
80
83
81
- expect ( npm [ 0 ] . cmd ) . to . equal ( "npm run postversion" ) ;
84
+ expect ( npm [ 0 ] . cmd ) . to . equal ( "npm run postversion --silent " ) ;
82
85
expect ( npm [ 0 ] . version ) . to . equal ( "2.0.0" ) ;
83
86
} ) ;
84
87
@@ -92,39 +95,42 @@ describe.skip("npm version hooks", () => {
92
95
} ,
93
96
} ) ;
94
97
95
- let cli = bump ( "-- major --commit --tag --push" ) ;
98
+ let cli = bump ( "major --commit --tag --push" ) ;
96
99
97
100
expect ( cli ) . to . have . stderr ( "" ) ;
98
101
expect ( cli ) . to . have . exitCode ( 0 ) ;
99
102
100
103
expect ( cli ) . to . have . stdout (
104
+ `${ check } Npm run preversion\n` +
101
105
`${ check } Updated package.json to 2.0.0\n` +
106
+ `${ check } Npm run version\n` +
102
107
`${ check } Git commit\n` +
103
108
`${ check } Git tag\n` +
109
+ `${ check } Npm run postversion\n` +
104
110
`${ check } Git push\n`
105
111
) ;
106
112
107
113
let bin = mocks . all ( ) ;
108
114
expect ( bin . length ) . to . equal ( 7 ) ;
109
115
110
116
// The preversion script runs before anything
111
- expect ( bin [ 0 ] . cmd ) . to . equal ( "npm run preversion" ) ;
117
+ expect ( bin [ 0 ] . cmd ) . to . equal ( "npm run preversion --silent " ) ;
112
118
expect ( bin [ 0 ] . version ) . to . equal ( "1.0.0" ) ;
113
119
114
120
// The version script runs after the version has been updated,
115
- expect ( bin [ 1 ] . cmd ) . to . equal ( "npm run version" ) ;
121
+ expect ( bin [ 1 ] . cmd ) . to . equal ( "npm run version --silent " ) ;
116
122
expect ( bin [ 1 ] . version ) . to . equal ( "2.0.0" ) ;
117
123
118
124
// Git commit happens after the version has been updated
119
- expect ( bin [ 2 ] . cmd ) . to . equal ( 'git commit package.json -m "release v2.0.0"' ) ;
125
+ expect ( bin [ 2 ] . cmd ) . to . equal ( 'git commit --message "release v2.0.0" package.json ' ) ;
120
126
expect ( bin [ 2 ] . version ) . to . equal ( "2.0.0" ) ;
121
127
122
128
// Git tag happens after the version has been updated
123
- expect ( bin [ 3 ] . cmd ) . to . equal ( " git tag -a v2.0.0 -m 2 .0.0" ) ;
129
+ expect ( bin [ 3 ] . cmd ) . to . equal ( ' git tag --annotate --message "release v2.0.0" v2 .0.0' ) ;
124
130
expect ( bin [ 3 ] . version ) . to . equal ( "2.0.0" ) ;
125
131
126
132
// The postversion script runs AFTER "git commit" and "git tag", but BEFORE "git push"
127
- expect ( bin [ 4 ] . cmd ) . to . equal ( "npm run postversion" ) ;
133
+ expect ( bin [ 4 ] . cmd ) . to . equal ( "npm run postversion --silent " ) ;
128
134
expect ( bin [ 4 ] . version ) . to . equal ( "2.0.0" ) ;
129
135
130
136
// Git push happens after everything else
0 commit comments