@@ -13,6 +13,8 @@ const formatCommitMessage = require('./lib/format-commit-message')
13
13
const cli = require ( './command' )
14
14
const standardVersion = require ( './index' )
15
15
16
+ const isWindows = process . platform === 'win32'
17
+
16
18
require ( 'chai' ) . should ( )
17
19
18
20
const cliPath = path . resolve ( __dirname , './bin/cli.js' )
@@ -248,74 +250,77 @@ describe('cli', function () {
248
250
} )
249
251
} )
250
252
251
- describe ( 'with mocked git' , function ( ) {
252
- it ( '--sign signs the commit and tag' , function ( ) {
253
- // mock git with file that writes args to gitcapture.log
254
- return mockGit ( 'require("fs").appendFileSync("gitcapture.log", JSON.stringify(process.argv.splice(2)) + "\\n")' )
255
- . then ( function ( unmock ) {
256
- execCli ( '--sign' ) . code . should . equal ( 0 )
257
-
258
- const captured = shell . cat ( 'gitcapture.log' ) . stdout . split ( '\n' ) . map ( function ( line ) {
259
- return line ? JSON . parse ( line ) : line
253
+ // TODO: investigate why mock-git does not play well with execFile on Windows.
254
+ if ( ! isWindows ) {
255
+ describe ( 'with mocked git' , function ( ) {
256
+ it ( '--sign signs the commit and tag' , function ( ) {
257
+ // mock git with file that writes args to gitcapture.log
258
+ return mockGit ( 'require("fs").appendFileSync("gitcapture.log", JSON.stringify(process.argv.splice(2)) + "\\n")' )
259
+ . then ( function ( unmock ) {
260
+ execCli ( '--sign' ) . code . should . equal ( 0 )
261
+
262
+ const captured = shell . cat ( 'gitcapture.log' ) . stdout . split ( '\n' ) . map ( function ( line ) {
263
+ return line ? JSON . parse ( line ) : line
264
+ } )
265
+ /* eslint-disable no-useless-escape */
266
+ captured [ captured . length - 4 ] . should . deep . equal ( [ 'commit' , '-S' , 'CHANGELOG.md' , 'package.json' , '-m' , '\"chore(release): 1.0.1\"' ] )
267
+ captured [ captured . length - 3 ] . should . deep . equal ( [ 'tag' , '-s' , 'v1.0.1' , '-m' , '\"chore(release): 1.0.1\"' ] )
268
+ /* eslint-enable no-useless-escape */
269
+ unmock ( )
260
270
} )
261
- /* eslint-disable no-useless-escape */
262
- captured [ captured . length - 4 ] . should . deep . equal ( [ 'commit' , '-S' , 'CHANGELOG.md' , 'package.json' , '-m' , '\"chore(release): 1.0.1\"' ] )
263
- captured [ captured . length - 3 ] . should . deep . equal ( [ 'tag' , '-s' , 'v1.0.1' , '-m' , '\"chore(release): 1.0.1\"' ] )
264
- /* eslint-enable no-useless-escape */
265
- unmock ( )
266
- } )
267
- } )
271
+ } )
268
272
269
- it ( 'exits with error code if git commit fails' , function ( ) {
270
- // mock git by throwing on attempt to commit
271
- return mockGit ( 'console.error("commit yourself"); process.exit(128);' , 'commit' )
272
- . then ( function ( unmock ) {
273
- const result = execCli ( )
274
- result . code . should . equal ( 1 )
275
- result . stderr . should . match ( / c o m m i t y o u r s e l f / )
273
+ it ( 'exits with error code if git commit fails' , function ( ) {
274
+ // mock git by throwing on attempt to commit
275
+ return mockGit ( 'console.error("commit yourself"); process.exit(128);' , 'commit' )
276
+ . then ( function ( unmock ) {
277
+ const result = execCli ( )
278
+ result . code . should . equal ( 1 )
279
+ result . stderr . should . match ( / c o m m i t y o u r s e l f / )
276
280
277
- unmock ( )
278
- } )
279
- } )
281
+ unmock ( )
282
+ } )
283
+ } )
280
284
281
- it ( 'exits with error code if git add fails' , function ( ) {
282
- // mock git by throwing on attempt to add
283
- return mockGit ( 'console.error("addition is hard"); process.exit(128);' , 'add' )
284
- . then ( function ( unmock ) {
285
- const result = execCli ( )
286
- result . code . should . equal ( 1 )
287
- result . stderr . should . match ( / a d d i t i o n i s h a r d / )
285
+ it ( 'exits with error code if git add fails' , function ( ) {
286
+ // mock git by throwing on attempt to add
287
+ return mockGit ( 'console.error("addition is hard"); process.exit(128);' , 'add' )
288
+ . then ( function ( unmock ) {
289
+ const result = execCli ( )
290
+ result . code . should . equal ( 1 )
291
+ result . stderr . should . match ( / a d d i t i o n i s h a r d / )
288
292
289
- unmock ( )
290
- } )
291
- } )
293
+ unmock ( )
294
+ } )
295
+ } )
292
296
293
- it ( 'exits with error code if git tag fails' , function ( ) {
294
- // mock git by throwing on attempt to commit
295
- return mockGit ( 'console.error("tag, you\'re it"); process.exit(128);' , 'tag' )
296
- . then ( function ( unmock ) {
297
- const result = execCli ( )
298
- result . code . should . equal ( 1 )
299
- result . stderr . should . match ( / t a g , y o u ' r e i t / )
297
+ it ( 'exits with error code if git tag fails' , function ( ) {
298
+ // mock git by throwing on attempt to commit
299
+ return mockGit ( 'console.error("tag, you\'re it"); process.exit(128);' , 'tag' )
300
+ . then ( function ( unmock ) {
301
+ const result = execCli ( )
302
+ result . code . should . equal ( 1 )
303
+ result . stderr . should . match ( / t a g , y o u ' r e i t / )
300
304
301
- unmock ( )
302
- } )
303
- } )
305
+ unmock ( )
306
+ } )
307
+ } )
304
308
305
- it ( 'doesn\'t fail fast on stderr output from git' , function ( ) {
306
- // mock git by throwing on attempt to commit
307
- return mockGit ( 'console.error("haha, kidding, this is just a warning"); process.exit(0);' , 'add' )
308
- . then ( function ( unmock ) {
309
- writePackageJson ( '1.0.0' )
309
+ it ( 'doesn\'t fail fast on stderr output from git' , function ( ) {
310
+ // mock git by throwing on attempt to commit
311
+ return mockGit ( 'console.error("haha, kidding, this is just a warning"); process.exit(0);' , 'add' )
312
+ . then ( function ( unmock ) {
313
+ writePackageJson ( '1.0.0' )
310
314
311
- const result = execCli ( )
312
- result . code . should . equal ( 1 )
313
- result . stderr . should . match ( / h a h a , k i d d i n g , t h i s i s j u s t a w a r n i n g / )
315
+ const result = execCli ( )
316
+ result . code . should . equal ( 1 )
317
+ result . stderr . should . match ( / h a h a , k i d d i n g , t h i s i s j u s t a w a r n i n g / )
314
318
315
- unmock ( )
316
- } )
319
+ unmock ( )
320
+ } )
321
+ } )
317
322
} )
318
- } )
323
+ }
319
324
320
325
describe ( 'lifecycle scripts' , ( ) => {
321
326
describe ( 'prerelease hook' , function ( ) {
0 commit comments