tasks/batch_git_clone.js
function npmInstall(path, success){

      var deferred = Q.defer();

      // 'success' is a flag passed from the perform cmd function which states whether the function ran
      if(success === false){
        deferred.resolve(success);
        return deferred.promise;
      }

      var hasPackage = grunt.file.isFile(path+'/package.json');

      if(options.npmInstall === true && hasPackage){

        var msg = '---> Install npm dependencies ==> '+path;
        var execString = 'cd '+path+' && npm install';

        grunt.log.writeln(msg);

        var child = exec(execString);

        // add events for logging
        child.stdout.on('data', function(data) {
          grunt.log.writeln(data);
        });
        child.stderr.on('data', function(data) {
          grunt.verbose.writeln(data);
        });
        child.on('close', function(code) {
          deferred.resolve(success);
        });

      }else{

        if(options.npmInstall === true) {
          var msg = '---> Skipping npm install as no package JSON was detected ==> ' + path;
          grunt.log.writeln(msg);
        }

        deferred.resolve();
      }


      return deferred.promise;

    }
function npmInstall(path, success){

      var deferred = Q.defer();

      // 'success' is a flag passed from the perform cmd function which states whether the function ran
      if(success === false){
        deferred.resolve(success);
        return deferred.promise;
      }

      var hasPackage = grunt.file.isFile(path+'/package.json');

      if(options.npmInstall === true && hasPackage){

        var msg = '---> Install npm dependencies ==> '+path;
        var execString = 'cd '+path+' && npm install';

        grunt.log.writeln(msg);

        var child = exec(execString);

        // add events for logging
        child.stdout.on('data', function(data) {
          grunt.log.writeln(data);
        });
        child.stderr.on('data', function(data) {
          grunt.verbose.writeln(data);
        });
        child.on('close', function(code) {
          deferred.resolve(success);
        });

      }else{

        if(options.npmInstall === true) {
          var msg = '---> Skipping npm install as no package JSON was detected ==> ' + path;
          grunt.log.writeln(msg);
        }

        deferred.resolve();
      }


      return deferred.promise;

    }
function npmInstall ( path , success ) { var deferred = Q . defer ( ) ; // 'success' is a flag passed from the perform cmd function which states whether the function ran if ( success === false ) { deferred . resolve ( success ) ; return deferred . promise ; } var hasPackage = grunt . file . isFile ( path + '/package.json' ) ; if ( options . npmInstall === true && hasPackage ) { var msg = '---> Install npm dependencies ==> ' + path ; var execString = 'cd ' + path + ' && npm install' ; grunt . log . writeln ( msg ) ; var child = exec ( execString ) ; // add events for logging child . stdout . on ( 'data' , function ( data ) { grunt . log . writeln ( data ) ; } ) ; child . stderr . on ( 'data' , function ( data ) { grunt . verbose . writeln ( data ) ; } ) ; child . on ( 'close' , function ( code ) { deferred . resolve ( success ) ; } ) ; } else { if ( options . npmInstall === true ) { var msg = '---> Skipping npm install as no package JSON was detected ==> ' + path ; grunt . log . writeln ( msg ) ; } deferred . resolve ( ) ; } return deferred . promise ; }
checks for a package.json then runs npm install if there is one.
checks for a package . json then runs npm install if there is one .