コード例 #1
0
 exitCodeOnSuccess: function (test) {
   test.expect(1);
   grunt.util.spawn({grunt: true, args: ['scsslint:success']}, function (error, result, code) {
     test.equal(code, 0);
     test.done();
   });
 },
コード例 #2
0
 setUp: function(done) {
   grunt.util.spawn({
     cmd: 'svn',
     args: ['up'],
     opts: {cwd: 'tmp/checkout/stable-tag-in-list/trunk'}
   }, done);
 },
コード例 #3
0
ファイル: index.js プロジェクト: ma-zal/grunt-date-suffix
  it("rotates to a different directory", function(done) {
    grunt.util.spawn({
      cmd: "grunt",
      args: ["datesuffix:test2"],
      opts: {
        cwd: sandboxPath
      }
    }, function(err) {
      if(err) {
        grunt.fail.fatal(out.stderr);
        return done(err);
      }

      fs.exists(Path.join(sandboxPath, testFileName), function(exist) {
        try {
          exist.should.not.be.ok;

          findMatch(rotatedFilePattern, testOutputPath, function(err, name) {
            if(err) return done(err);
            try {
              should.exist(name);

              fs.unlink(Path.join(testOutputPath, name), done);
            } catch(err) {
              done(err);
            }
          });
        } catch(err) {
          done(err);
        }
      });
    });
  });
コード例 #4
0
ファイル: sstp.js プロジェクト: k-kinzal/grunt-sstp
 it('run fatal task.', function(done) {
   var callback = function(err, result) {
     expect(result.stdout).to.have.string("Fatal error: Grunt fatal test.");
     done();
   };
   grunt.util.spawn({grunt: true,args: ['fatal', '--no-color']}, callback);
 });
コード例 #5
0
exports.svnInit = function(test){
	test.expect(1);

	var svnPath = 'https://svn.sinaapp.com/gruntsvnworkflow/1/svn-workflow/test/svninit/inner';

	$grunt.util.spawn({
		cmd: 'svn',
		args: ['info', svnPath],
		autoExecError : false
	}, function(error, result, code){

		var json = result.stdout.split(/\n/g).reduce(function(obj, str){
			var index = str.indexOf(':');
			var key = str.substr(0, index).trim().toLowerCase();
			var value = str.substr(index + 1).trim();
			obj[key] = value;
			return obj;
		}, {});

		test.equal(
			json.url,
			svnPath,
			'Should created svn folder : ' + svnPath + '.'
		);

		test.done();
	});
};
コード例 #6
0
 exitCodeOnFailure: function (test) {
   test.expect(1);
   grunt.util.spawn({grunt: true, args: ['scsslint']}, function (error, result, code) {
     test.notEqual(code, 0);
     test.done();
   });
 },
コード例 #7
0
ファイル: jest.js プロジェクト: ConAntonakos/react
function run(done, coverage) {
  grunt.log.writeln('running jest');

  var args = [
    path.join('node_modules', 'jest-cli', 'bin', 'jest'),
    '--runInBand',
  ];
  if (coverage) {
    args.push('--coverage');
  }
  grunt.util.spawn({
    cmd: 'node',
    args: args,
    opts: {
      stdio: 'inherit',
      env: Object.assign({}, process.env, {
        NODE_ENV: 'test',
      }),
    },
  }, function(spawnErr, result, code) {
    if (spawnErr) {
      grunt.log.error('jest failed');
      grunt.log.error(spawnErr);
    } else {
      grunt.log.ok('jest passed');
    }
    grunt.log.writeln(result.stdout);

    done(code === 0);
  });
}
コード例 #8
0
  testLoadsDevelopmentEnvironmentByDefault: function (test) {
    test.expect(9);

    grunt.util.spawn({
      grunt: true,
      args: [
        '--gruntfile', path.join(__dirname, "fixture", "gruntfiles", "development.js"),
        "test-environmental"
      ]
    }, function (error, output, code) {
      var taskResults = assertTaskWasSuccessful(test, error, output, code);

      if (taskResults.length === 4) {
        test.equal(taskResults[1].indexOf("NODE_APP_PREFIX"), -1,
            "NODE_APP_PREFIX shouldn't be in the environment before code runs");
        // data from test/fixture/test_envs/development.sh
        test.notEqual(taskResults[3].indexOf("NODE_APP_PREFIX=ENV_TEST_DEV"), -1,
            "NODE_APP_PREFIX should be ENV_TEST_DEV");
        test.notEqual(taskResults[3].indexOf("ENV_TEST_DEV_INFO=development"), -1,
            "ENV_TEST_DEV_INFO should be 'development'");
        test.notEqual(taskResults[3].indexOf("this=that"), -1,
            "Environment should contain complete, exact string for value containing an equal sign");
      }

      test.done();
    });
  },
コード例 #9
0
    testWithTaskOptionsOverwriting : function(test) {
        
        test.expect(1);
        
        // Executes the plugin using a new Grunt Process
        grunt.util.spawn({
            grunt: true,
            args: ['phpdocumentor:testWithTaskOptionsOverwriting', '--no-color']
        }, function(error, result, code) {

            // If an error occured we display the associated log
            if(code > 0) {
                
                console.log(result);
                
            }
            
            // We test that the output of the command contains the phpDocumentor 'help' command usage string
            //  Usage : 
            //    help [--xml] [--format="..."] [--raw] [command_name]
            test.ok(result.stdout.indexOf('help [--xml] [--format="..."] [--raw] [command_name]') > 0);

            // Indicates that the execute of our test is terminated
            test.done();

        });
        
    }
コード例 #10
0
ファイル: sstp.js プロジェクト: k-kinzal/grunt-sstp
 it('run success task.', function(done) {
   var callback = function(err, result) {
     expect(result.stdout).to.have.string('Done, without errors.');
     done();
   };
   grunt.util.spawn({grunt: true,args: ['success', '--no-color']}, callback);
 });
コード例 #11
0
 before: function(test) {
   grunt.util.spawn({
     cmd: 'test/fixtures/test_repo'
   }, function(err) {
     test.done(err);
   });
 },
コード例 #12
0
 it('should undo the last migration', function(done) {
   grunt.util.spawn({ grunt: true, args: ['sequelize:undo'] }, function(error, result) {
     console.log(result);
     assert.equal(result.code, 0);
     done();
   });
 });
コード例 #13
0
  testLoadsTargetEnvironment: function (test) {
    test.expect(8);

    grunt.util.spawn({
      grunt: true,
      args: [
        '--gruntfile', path.join(__dirname, "fixture", "gruntfiles", "production.js"),
        "test-environmental"
      ]
    }, function (error, output, code) {
      var taskResults = assertTaskWasSuccessful(test, error, output, code);

      if (taskResults.length === 4) {
        test.equal(taskResults[1].indexOf("NODE_APP_PREFIX"), -1,
            "NODE_APP_PREFIX shouldn't be in the environment before code runs");
        // data from test/fixture/test_envs/production.sh
        test.notEqual(taskResults[3].indexOf("NODE_APP_PREFIX=ENV_TEST_PROD"), -1,
            "NODE_APP_PREFIX should be ENV_TEST_PROD");
        test.notEqual(taskResults[3].indexOf("ENV_TEST_PROD_INFO=production"), -1,
            "ENV_TEST_PROD_INFO should be 'production'");
      }

      test.done();
    });
  },
コード例 #14
0
exports.compileScss = function(test){
  var grunt = require('grunt'),
      fs = require('fs'),
      jsdiff = require('diff'),
      t = test,
      filename = 'select2-bootstrap.css',
      patchfile = 'tests/support/scss.patch',

      child = grunt.util.spawn({
        cmd: 'grunt',
        args: ['sass:test']
      }, function() {
        var readFile = function(name) { return fs.readFileSync(name, {encoding: 'utf8'}) },
            orig = readFile(filename),
            generated = readFile('tmp/'+filename),
            patch = readFile(patchfile),
            diff = jsdiff.createPatch(filename, orig, generated);

        // Save the output for future tests.
        // fs.writeFileSync(patchfile, diff);

        t.equal(patch, diff);
        t.done();
      });
};
コード例 #15
0
  testIncludesItemsFromInjectOptionsIntoEnvironment: function (test) {
    test.expect(8);

    grunt.util.spawn({
      grunt: true,
      args: [
        '--gruntfile', path.join(__dirname, "fixture", "gruntfiles", "inject.js"),
        "test-environmental"
      ]
    }, function(error, output, code) {
      var taskResults = assertTaskWasSuccessful(test, error, output, code);

      if (taskResults.length === 4) {
        // data from test/fixture/test_envs/development.sh
        test.notEqual(taskResults[3].indexOf("NODE_APP_PREFIX=ENV_TEST_DEV"), -1,
            "NODE_APP_PREFIX should be ENV_TEST_DEV");
        test.notEqual(taskResults[3].indexOf("ENV_TEST_DEV_INJECTED_A=alpha"), -1,
            "ENV_TEST_DEV_INJECTED_A should be 'alpha'");
        test.notEqual(taskResults[3].indexOf("ENV_TEST_DEV_INJECTED_B=omega"), -1,
            "ENV_TEST_DEV_INJECTED_B should be 'omega'");
      }

      test.done();
    });
  }
コード例 #16
0
/**
 * Public function to notify
 * @param options - options.message is the only required value. title is recommended. subtitle is going overboard.
 * @param [cb] - optional callback. function(err, stdout, stderr)
 */
function notify(options, cb) {
  var title = escapeForCommandLine(options.title),
    message = escapeForCommandLine(options.message),
    subtitle = escapeForCommandLine(options.subtitle),
    commandline;

  if (!options.message) {
    return cb && cb(!options.message && 'Message is required');
  }

  if (isMac) {
    commandline = [TERMINAL_NOTIFIER_APP,
      (title ? '-title "' + title + '"' : ''),
      '-message "' + message + '"',
      (subtitle ? '-subtitle "' + subtitle + '"' : ''),
      '-group "' + process.cwd() + '"',
      (TERMINAL_PROGRAM ? ' -activate "' + TERMINAL_PROGRAM + '"' : '')].join(' ');

    // grunt.spawn isn't being used because I couldn't get the app to recognize the arguments
    return ChildProcess.exec(commandline, cb);
  }

  if (isLinux) {
    return grunt.util.spawn({
      cmd: 'notify-send',
      args: [
        title,
        subtitle ? subtitle + ' ' + message : message
      ]
    }, cb);
  }

  // not able to run
  return false;
}
コード例 #17
0
ファイル: server.js プロジェクト: tandrewnichols/drbob
 var startServer = function() {
   process.on('exit', kill);
   server = grunt.util.spawn({
     cmd: 'node',
     args: ['service.js'],
     env: process.env
   }, function(err, code) {
     if (code && code > 0) {
       grunt.log.writeln(err, results, code);
     }
   });
   server.stdout.on('data', function(data) {
     data = data.toString();
     if (data.indexOf('listening on port') > -1) {
       done();
     }
     process.stdout.write(chalk.cyan('[ DEV ]') + '  ' + data);
   });
   var error = function(data) {
     console.log(chalk.red('>>'), data.toString());
   };
   server.stderr.on('data', error);
   server.stdout.on('error', error);
   server.on('close', function(code, signal) {
     if (signal === 'SIGKILL') {
       process.removeListener('exit', kill);
       startServer();
     }
   });
 };
コード例 #18
0
ファイル: newpost_test.js プロジェクト: paulovida/happyplan
    grunt.util._.each(testsOpts, function(opts, key) {
      opts.push('happyplan:newpost');
      opts.push('--base=test/sandbox');
      grunt.util.spawn({
        cmd: 'grunt',
        args: opts
      },
      function doneFunction(error, result, code) {
        if (error) {
          if (result.stdout) {
            console.log("\n" + result.stdout);
          }
          if (result.sterr) {
            console.log("\n" + result.sterr);
          }
          
          throw error;
        }
        
        test.deepEqual(
          grunt.file.read('test/expected/newpost/' + key + '.md'),
          grunt.file.read('test/sandbox/src/_posts/_drafts/' +grunt.template.today('yyyy-mm-dd') + '-' + key + '.md'),
          'Created Posts should be like expectations'
        );

        testI++;
        if (testI===testsOptsLength) {
          test.done();
        }
      });
    });
コード例 #19
0
    testWithTarget : function(test) {
        
        test.expect(2);
        
        // At the beginning no 'target/testWithTarget' directory exists
        test.ok(!fs.existsSync('target/testWithTarget'));
        
        // Executes the plugin using a new Grunt Process
        grunt.util.spawn({
            grunt: true,
            args: ['phpdocumentor:testWithTarget', '--no-color']
        }, function(error, result, code) {

            // If an error occured we display the associated log
            if(code > 0) {
                
                console.log(result);
                
            }
              
            // A 'target/testWithTarget' directory must have been created
            test.ok(fs.existsSync('target/testWithTarget'));
              
            // Indicates that the execute of our test is terminated
            test.done();

        });
        
    },
コード例 #20
0
ファイル: release.js プロジェクト: EtaiG/react
 grunt.util.spawn(gitCommit, function() {
   if (tag) {
     grunt.util.spawn(gitTag, cb);
   } else {
     cb();
   }
 });
コード例 #21
0
    testForTemplateList : function(test) {
        
        test.expect(9);
        
        // Executes the plugin using a new Grunt Process
        grunt.util.spawn({
            grunt: true,
            args: ['phpdocumentor:testForTemplateList', '--no-color']
        }, function(error, result, code) {

            // If an error occured we display the associated log
            if(code > 0) {
                
                console.log(result);
                
            }
            
            // We test that the output of the command contains the phpDocumentor 'template:string' command strings
            test.ok(result.stdout.indexOf('Available templates:') > 0);
            test.ok(result.stdout.indexOf('* abstract') > 0);
            test.ok(result.stdout.indexOf('* checkstyle') > 0);
            test.ok(result.stdout.indexOf('* new-black') > 0);
            test.ok(result.stdout.indexOf('* old-ocean') > 0);
            test.ok(result.stdout.indexOf('* responsive') > 0);
            test.ok(result.stdout.indexOf('* responsive-twig') > 0);
            test.ok(result.stdout.indexOf('* xml') > 0);
            test.ok(result.stdout.indexOf('* zend') > 0);
            
            // Indicates that the execute of our test is terminated
            test.done();

        });
        
    },
コード例 #22
0
    testForParse : function(test) {
      
        test.expect(3);
        
        // Executes the plugin using a new Grunt Process
        grunt.util.spawn({
            grunt: true,
            args: ['phpdocumentor:testForParse', '--no-color']
        }, function(error, result, code) {

            // If an error occured we display the associated log
            if(code > 0) {
                
                console.log(result);
                
            }
            
            // We test that the output of the command contains the phpDocumentor 'parse' command strings
            //  Collecting files .. OK
            //  Initializing parser .. OK
            //  Parsing files
            test.ok(result.stdout.indexOf('Collecting files .. OK') > 0);
            test.ok(result.stdout.indexOf('Initializing parser .. OK') > 0);
            test.ok(result.stdout.indexOf('Parsing files') > 0);

            // Indicates that the execute of our test is terminated
            test.done();

        });
        
    },
コード例 #23
0
 setUp: function(done) {
   grunt.util.spawn({
     cmd: 'git',
     args: ['checkout', 'gh-pages'],
     opts: {cwd: 'tmp/repo'}
   }, done);
 },
コード例 #24
0
 exitCodeAndOutputOnMissingRuby: function (test) {
   test.expect(2);
   grunt.util.spawn({grunt: true, args: ['scsslint'], opts: {env: {PATH: '.'}}}, function (error, result, code) {
     test.notEqual(code, 0);
     test.ok(result.stdout.match('Please make sure you have ruby installed'));
     test.done();
   });
 },
コード例 #25
0
 tearDown: function (done) {
   grunt.util.spawn({
     grunt: true,
     args: ['clean']
   }, function() {
     done();
   });
 },
コード例 #26
0
ファイル: sstp.js プロジェクト: k-kinzal/grunt-sstp
 it('run log-fail task.', function(done) {
   var callback = function(err, result) {
     expect(result.stdout).to.have.string("Grunt error test.");
     expect(result.stdout).to.have.string("Done, without errors.");
     done();
   };
   grunt.util.spawn({grunt: true,args: ['log-fail', '--no-color']}, callback);
 });
コード例 #27
0
ファイル: sstp.js プロジェクト: k-kinzal/grunt-sstp
 it('run fail-warning task.', function(done) {
   var callback = function(err, result) {
     expect(result.stdout).to.have.string("Grunt warning test.");
     expect(result.stdout).to.have.string("Aborted due to warnings.");
     done();
   };
   grunt.util.spawn({grunt: true,args: ['fail-warning', '--no-color']}, callback);
 });
コード例 #28
0
ファイル: admin.js プロジェクト: musicDr1ven/calipso
function rebuildSass(req, res, template, block, next) {

	grunt.util.spawn({ grunt: true, args: ['default'] },function() {
		  grunt.log.ok('Done running Grunt compass.');
		  res.redirect('/admin/core/config');
		});
	
	
}
コード例 #29
0
 it('should run tasks when given empty hooks', (done) => {
   grunt.util.spawn({
     cmd: 'grunt',
     args: ['--gruntfile', emptyHooks, 'plugin_tester']
   }, (error, result) => {
     assert(result.stdout.includes('Plugin is printing'));
     done();
   });
 });
コード例 #30
0
 it('passes yeoman test', function(done) {
   grunt.util.spawn({
     cmd: 'yeoman',
     args: ['test']
   }, function(err) {
     should.not.exist(err);
     done();
   });
 });