@@ -13,7 +13,10 @@ var gutil = require('gulp-util'),
13
13
fs = require ( 'fs' ) ,
14
14
open = require ( 'gulp-open' ) ,
15
15
path = require ( 'path' ) ,
16
- spawn = require ( 'child_process' ) . spawn ;
16
+ spawn = require ( 'child_process' ) . spawn ,
17
+ mapstream = require ( 'map-stream' ) ,
18
+ nicePackage = require ( 'gulp-nice-package' ) ,
19
+ shrinkwrap = require ( 'gulp-shrinkwrap' ) ;
17
20
18
21
/**
19
22
* Assigns default tasks to your gulp instance
@@ -63,6 +66,13 @@ module.exports = function (gulp, options) {
63
66
complexity : {
64
67
destDir : './target/complexity' ,
65
68
options : { } // https://github.com/philbooth/complexity-report#command-line-options
69
+ } ,
70
+ nicePackage : {
71
+ spec : 'npm' ,
72
+ options : {
73
+ warnings : false ,
74
+ recommendations : false
75
+ }
66
76
}
67
77
} ;
68
78
@@ -312,11 +322,40 @@ module.exports = function (gulp, options) {
312
322
313
323
} ) ;
314
324
325
+ // ----------------
326
+ // shrinkwrap
327
+ // ----------------
328
+
329
+ function validatePackageJson ( ) {
330
+ return gulp . src ( 'package.json' )
331
+ . pipe ( nicePackage ( gulp . options . nicePackage . spec , gulp . options . nicePackage . options ) ) ;
332
+ }
333
+
334
+ gulp . task ( 'nice-package' , 'Validates package.json' , function ( ) {
335
+ var isValid = true ;
336
+ return validatePackageJson ( )
337
+ . pipe ( mapstream ( function ( file , cb ) {
338
+ isValid = file . nicePackage . valid ;
339
+ cb ( null , file ) ;
340
+ } ) )
341
+ . on ( 'end' , function ( ) {
342
+ if ( ! isValid ) {
343
+ process . emit ( 'exit' ) ;
344
+ }
345
+ } ) ;
346
+ } ) ;
347
+
348
+ gulp . task ( 'shrinkwrap' , 'Cleans package.json deps and generates npm-shrinkwrap.json' , function ( ) {
349
+ return validatePackageJson ( )
350
+ . pipe ( shrinkwrap ( ) )
351
+ . pipe ( gulp . dest ( './' ) ) ;
352
+ } ) ;
353
+
315
354
// ----------------
316
355
// combo tasks
317
356
// ----------------
318
357
319
- gulp . task ( 'ci' , 'Lint, tests and test coverage' , [ 'lint' , 'felint' , 'test-cover' ] ) ;
358
+ gulp . task ( 'ci' , 'Lint, tests and test coverage' , [ 'lint' , 'felint' , 'test-cover' , 'nice-package' ] ) ;
320
359
321
360
function getTestAndLintPaths ( ) {
322
361
var paths = gulp . options . paths . lint . concat ( gulp . options . paths . test ) ;
0 commit comments