commands/check.js
function(args, done) {
  function run(cmd) {
    return function(cb) {
      debug('testing `%s`', cmd);
      var parts = cmd.split(' ');
      var bin = parts.shift();
      var args = parts;
      var completed = false;

      var child = spawn(bin, args, {
        cwd: args['<directory>']
      })
        .on('error', function(err) {
          completed = true;
          done(new Error(cmd + ' failed: ' + err.message));
        });

      child.stderr.pipe(process.stderr);

      if (cmd === 'npm start') {
        setTimeout(function() {
          if (completed) {
            return;
          }

          completed = true;
          child.kill('SIGKILL');
          done();
        }, 5000);
      }

      child.on('close', function(code) {
        if (completed) {
          return;
        }

        completed = true;

        if (code === 0) {
          done();
          return;
        }

        cb(new Error(cmd + ' failed'));
      });
    };
  }
  debug('checking first run');


  var dir = path.resolve(args['<directory>']);

  var pkg = require(path.join(dir, 'package.json'));

  debug('clearing local node_modules to make sure install works');

  rimraf(dir + '/node_modules/**/*', function(err) {
    if (err) {
      return done(err);
    }
    var tasks = [
      run('npm install'),
      run('npm test')
    ];

    if (pkg.scripts.start) {
      tasks.push(run('npm start'));
    }

    async.series(tasks, function(err, results) {
      if (err) {
        return done(err);
      }
      done(null, results);
    });
  });
}
function(args, done) {
  function run(cmd) {
    return function(cb) {
      debug('testing `%s`', cmd);
      var parts = cmd.split(' ');
      var bin = parts.shift();
      var args = parts;
      var completed = false;

      var child = spawn(bin, args, {
        cwd: args['<directory>']
      })
        .on('error', function(err) {
          completed = true;
          done(new Error(cmd + ' failed: ' + err.message));
        });

      child.stderr.pipe(process.stderr);

      if (cmd === 'npm start') {
        setTimeout(function() {
          if (completed) {
            return;
          }

          completed = true;
          child.kill('SIGKILL');
          done();
        }, 5000);
      }

      child.on('close', function(code) {
        if (completed) {
          return;
        }

        completed = true;

        if (code === 0) {
          done();
          return;
        }

        cb(new Error(cmd + ' failed'));
      });
    };
  }
  debug('checking first run');


  var dir = path.resolve(args['<directory>']);

  var pkg = require(path.join(dir, 'package.json'));

  debug('clearing local node_modules to make sure install works');

  rimraf(dir + '/node_modules/**/*', function(err) {
    if (err) {
      return done(err);
    }
    var tasks = [
      run('npm install'),
      run('npm test')
    ];

    if (pkg.scripts.start) {
      tasks.push(run('npm start'));
    }

    async.series(tasks, function(err, results) {
      if (err) {
        return done(err);
      }
      done(null, results);
    });
  });
}
function ( args , done ) { function run ( cmd ) { return function ( cb ) { debug ( 'testing `%s`' , cmd ) ; var parts = cmd . split ( ' ' ) ; var bin = parts . shift ( ) ; var args = parts ; var completed = false ; var child = spawn ( bin , args , { cwd : args [ '<directory>' ] } ) . on ( 'error' , function ( err ) { completed = true ; done ( new Error ( cmd + ' failed: ' + err . message ) ) ; } ) ; child . stderr . pipe ( process . stderr ) ; if ( cmd === 'npm start' ) { setTimeout ( function ( ) { if ( completed ) { return ; } completed = true ; child . kill ( 'SIGKILL' ) ; done ( ) ; } , 5000 ) ; } child . on ( 'close' , function ( code ) { if ( completed ) { return ; } completed = true ; if ( code === 0 ) { done ( ) ; return ; } cb ( new Error ( cmd + ' failed' ) ) ; } ) ; } ; } debug ( 'checking first run' ) ; var dir = path . resolve ( args [ '<directory>' ] ) ; var pkg = require ( path . join ( dir , 'package.json' ) ) ; debug ( 'clearing local node_modules to make sure install works' ) ; rimraf ( dir + '/node_modules/**/*' , function ( err ) { if ( err ) { return done ( err ) ; } var tasks = [ run ( 'npm install' ) , run ( 'npm test' ) ] ; if ( pkg . scripts . start ) { tasks . push ( run ( 'npm start' ) ) ; } async . series ( tasks , function ( err , results ) { if ( err ) { return done ( err ) ; } done ( null , results ) ; } ) ; } ) ; }
If I clone this repo and run `npm install && npm test` does it work? If there is an `npm start`, run that as well and make sure it stays up for 5 seconds and doesn't return an error.
If I clone this repo and run npm install && npm test does it work? If there is an npm start run that as well and make sure it stays up for 5 seconds and doesn t return an error .