@@ -17,6 +17,7 @@ const vfs = require('vinyl-fs');
1717const path = require ( 'path' ) ;
1818const fs = require ( 'fs' ) ;
1919const pall = require ( 'p-all' ) ;
20+ const task = require ( './lib/task' ) ;
2021
2122/**
2223 * Hygiene works by creating cascading subsets of all our files and
@@ -205,6 +206,33 @@ gulp.task('tslint', () => {
205206 ] ) . pipe ( es . through ( ) ) ;
206207} ) ;
207208
209+ function checkPackageJSON ( actualPath ) {
210+ const actual = require ( path . join ( __dirname , '..' , actualPath ) ) ;
211+ const rootPackageJSON = require ( '../package.json' ) ;
212+
213+ for ( let depName in actual . dependencies ) {
214+ const depVersion = actual . dependencies [ depName ] ;
215+ const rootDepVersion = rootPackageJSON . dependencies [ depName ] ;
216+ if ( ! rootDepVersion ) {
217+ // missing in root is allowed
218+ continue ;
219+ }
220+ if ( depVersion !== rootDepVersion ) {
221+ this . emit ( 'error' , `The dependency ${ depName } in '${ actualPath } ' (${ depVersion } ) is different than in the root package.json (${ rootDepVersion } )` ) ;
222+ }
223+ }
224+ }
225+
226+ const checkPackageJSONTask = task . define ( 'check-package-json' , ( ) => {
227+ return gulp . src ( 'package.json' )
228+ . pipe ( es . through ( function ( ) {
229+ checkPackageJSON . call ( this , 'remote/package.json' ) ;
230+ checkPackageJSON . call ( this , 'remote/web/package.json' ) ;
231+ } ) ) ;
232+ } ) ;
233+ gulp . task ( checkPackageJSONTask ) ;
234+
235+
208236function hygiene ( some ) {
209237 let errorCount = 0 ;
210238
@@ -393,7 +421,7 @@ function createGitIndexVinyls(paths) {
393421 . then ( r => r . filter ( p => ! ! p ) ) ;
394422}
395423
396- gulp . task ( 'hygiene' , ( ) => hygiene ( ) ) ;
424+ gulp . task ( 'hygiene' , task . series ( checkPackageJSONTask , ( ) => hygiene ( ) ) ) ;
397425
398426// this allows us to run hygiene as a git pre-commit hook
399427if ( require . main === module ) {
0 commit comments