33var autoprefixer = require ( 'gulp-autoprefixer' ) ;
44var del = require ( 'del' ) ;
55var format = require ( 'gulp-clang-format' ) ;
6+ var exec = require ( 'child_process' ) . exec ;
67var fork = require ( 'child_process' ) . fork ;
78var gulp = require ( 'gulp' ) ;
89var gulpPlugins = require ( 'gulp-load-plugins' ) ( ) ;
@@ -13,6 +14,7 @@ var madge = require('madge');
1314var merge = require ( 'merge' ) ;
1415var merge2 = require ( 'merge2' ) ;
1516var path = require ( 'path' ) ;
17+ var semver = require ( 'semver' ) ;
1618var watch = require ( 'gulp-watch' ) ;
1719
1820var clean = require ( './tools/build/clean' ) ;
@@ -49,8 +51,37 @@ var angularBuilder = {
4951 cleanup : function ( ) { }
5052} ;
5153
52- // Note: when DART_SDK is not found, all gulp tasks ending with `.dart` will be skipped.
54+ ( function checkNodeAndNpmVersions ( ) {
55+ var requiredNpmVersion = '>=2.9.0' ;
56+ var requiredNodeVersion = '>=0.10.x' ; // TODO: bump this to 0.12 once travis runs on 0.12
57+
58+ exec ( 'npm --version' , function ( e , stdout ) {
59+ var foundNpmVersion = semver . clean ( stdout ) ;
60+ var foundNodeVersion = process . version ;
61+ var issues = [ ] ;
62+
5363
64+ if ( ! semver . satisfies ( foundNodeVersion , requiredNodeVersion ) ) {
65+ issues . push ( 'You are running unsupported node version. Found: ' + foundNodeVersion +
66+ ' Expected: ' + requiredNodeVersion ) ;
67+ }
68+
69+ if ( ! semver . satisfies ( foundNpmVersion , requiredNpmVersion ) ) {
70+ issues . push ( 'You are running unsuported npm version. Found: ' + foundNpmVersion +
71+ ' Expected: ' + requiredNpmVersion ) ;
72+ }
73+
74+ if ( issues . length ) {
75+ // TODO: in the future we should error, but let's just display the warning for a few days first
76+ console . warn ( Array ( 80 ) . join ( '!' ) ) ;
77+ console . warn ( 'Your environment is not in a good shape. Following issues were found:' ) ;
78+ issues . forEach ( function ( issue ) { console . warn ( ' - ' + issue ) } ) ;
79+ console . warn ( Array ( 80 ) . join ( '!' ) ) ;
80+ }
81+ } ) ;
82+ } ( ) )
83+
84+ // Note: when DART_SDK is not found, all gulp tasks ending with `.dart` will be skipped.
5485var DART_SDK = require ( './tools/build/dartdetect' ) ( gulp ) ;
5586
5687// -----------------------
0 commit comments