コード例 #1
0
ファイル: index.js プロジェクト: gruntjs/grunt-legacy-config
config.requires = function() {
  var p = grunt.util.pluralize;
  var props = grunt.util.toArray(arguments).map(config.getPropString);
  var msg = 'Verifying propert' + p(props.length, 'y/ies') +
    ' ' + grunt.log.wordlist(props) + ' exist' + p(props.length, 's') +
    ' in config...';
  grunt.verbose.write(msg);
  var failProps = config.data && props.filter(function(prop) {
    return config.get(prop) == null;
  }).map(function(prop) {
    return '"' + prop + '"';
  });
  if (config.data && failProps.length === 0) {
    grunt.verbose.ok();
    return true;
  } else {
    grunt.verbose.or.write(msg);
    grunt.log.error().error('Unable to process task.');
    if (!config.data) {
      throw grunt.util.error('Unable to load config.');
    } else {
      throw grunt.util.error('Required config propert' +
        p(failProps.length, 'y/ies') + ' ' + failProps.join(', ') + ' missing.');
    }
  }
};
コード例 #2
0
    default_options: function (test) {
        test.expect(1);

        var actual = grunt.file.read('tmp/default_options/some.html');
        var expected = grunt.file.read('test/expected/default_options/some.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'default_options.');

        test.done();
    },
コード例 #3
0
    custom_renderer: function (test) {
        test.expect(1);

        var actual = grunt.file.read('tmp/custom_renderer/some.html');
        var expected = grunt.file.read('test/expected/custom_renderer/some.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'custom_renderer.');

        test.done();
    },
コード例 #4
0
  sourceMapLessInline: function(test) {
    test.expect(1);

    var expected = read('test/fixtures/style3.less');
    var sourceMap = grunt.file.readJSON('tmp/sourceMapLessInline.css.map').sourcesContent[0];
    test.equal(grunt.util.normalizelf(sourceMap), grunt.util.normalizelf(expected), 'should put the less file into the generated sourceMap instead of referencing them.');

    test.done();
  },
コード例 #5
0
    layout: function (test) {
        test.expect(1);

        var actual = grunt.file.read('tmp/layout/some.html');
        var expected = grunt.file.read('test/expected/layout/some.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'layout.');

        test.done();
    },
コード例 #6
0
    layout_api: function (test) {
        test.expect(1);

        var actual = grunt.file.read('tmp/layout_api/Object_prototype.html');
        var expected = grunt.file.read('test/expected/layout_api/Object_prototype.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'layout_api.');

        test.done();
    }
コード例 #7
0
ファイル: index.js プロジェクト: gruntjs/grunt-legacy-task
 this.options = function() {
   var targetObj = grunt.config([name, target]);
   var args = [{}].concat(grunt.util.toArray(arguments)).concat([
     grunt.config([name, 'options']),
     grunt.util.kindOf(targetObj) === 'object' ? targetObj.options : {}
   ]);
   var options = grunt.util._.extend.apply(null, args);
   grunt.verbose.writeflags(options, 'Options');
   return options;
 };
コード例 #8
0
    files_array_format: function (test) {
        test.expect(2);

        var actual = grunt.file.read('tmp/files_array_format/some.html');
        var expected = grunt.file.read('test/expected/files_array_format/some.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'files_array_format some.html.');

        actual = grunt.file.read('tmp/files_array_format/parent.some.html');
        expected = grunt.file.read('test/expected/files_array_format/parent.some.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'files_array_format parent.some.html.');

        test.done();
    },
コード例 #9
0
    index: function (test) {
        test.expect(2);

        var actual = grunt.file.read('tmp/xtpl/a-xtpl.js', 'utf-8');
        var expected = grunt.util.normalizelf(grunt.file.read('test/expected/a-xtpl.js', 'utf-8'));
        test.equal(actual, expected, 'should build proper compiled a-xtpl file.');

        var actualDep = grunt.file.read('tmp/xtpl/b-xtpl.js', 'utf-8');
        var expectedDep = grunt.util.normalizelf(grunt.file.read('test/expected/b-xtpl.js', 'utf-8'));
        test.equal(actualDep, expectedDep, 'should have proper compiled b-xtpl file.');

        test.done();
    }
コード例 #10
0
    before_after_compile: function (test) {
        test.expect(2);

        var actual = grunt.file.read('tmp/before_after_compile/some.html');
        var expected = grunt.file.read('test/expected/before_after_compile/some.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'before_after_compile some.html.');

        actual = grunt.file.read('tmp/before_after_compile/some2.html');
        expected = grunt.file.read('test/expected/before_after_compile/some2.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'before_after_compile some2.html.');

        test.done();
    },
コード例 #11
0
  default_options: function(test) {
    test.expect(1);
    var actual = grunt.util.normalizelf( grunt.file.read('tmp/default_options.js') );
    var expected = grunt.util.normalizelf( grunt.file.read('test/expected/default_options.js') );
    test.equal(actual, expected, 'output file doesn\'t match expected result');

    //test.doesNotThrow(
    //  function() {
    //    /*jshint evil:true */
    //    eval(actual);
    //  }
    //);

    test.done();
  },
コード例 #12
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();

        });
        
    },
コード例 #13
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();
        }
      });
    });
コード例 #14
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();

        });
        
    },
コード例 #15
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();

        });
        
    }
コード例 #16
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);
  });
}
コード例 #17
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();

        });
        
    },
コード例 #18
0
 task.phantomRunner(options, function(err,status) {
   if (status && status.failed > 0) {
     grunt.log.error(grunt.util._("%s of %s total specs failed").sprintf(status.failed, status.total));
   }
   if (err) grunt.log.error(err);
   done(!err && status.failed === 0);
 });
コード例 #19
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);
        }
      });
    });
  });
コード例 #20
0
 before: function(test) {
   grunt.util.spawn({
     cmd: 'test/fixtures/test_repo'
   }, function(err) {
     test.done(err);
   });
 },
コード例 #21
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();
      });
};
コード例 #22
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();
   });
 });
コード例 #23
0
 setUp: function(done) {
   grunt.util.spawn({
     cmd: 'svn',
     args: ['up'],
     opts: {cwd: 'tmp/checkout/stable-tag-in-list/trunk'}
   }, done);
 },
コード例 #24
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();
	});
};
コード例 #25
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();
    });
  },
コード例 #26
0
ファイル: release.js プロジェクト: EtaiG/react
 grunt.util.spawn(gitCommit, function() {
   if (tag) {
     grunt.util.spawn(gitTag, cb);
   } else {
     cb();
   }
 });
コード例 #27
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;
}
コード例 #28
0
 setUp: function(done) {
   grunt.util.spawn({
     cmd: 'git',
     args: ['checkout', 'gh-pages'],
     opts: {cwd: 'tmp/repo'}
   }, done);
 },
コード例 #29
0
ファイル: utils.js プロジェクト: 398218995/angular.js
  build: function(config, fn){
    var files = grunt.file.expand(config.src);
    var styles = config.styles;
    var processedStyles;
    //concat
    var src = files.map(function(filepath) {
      return grunt.file.read(filepath);
    }).join(grunt.util.normalizelf('\n'));
    //process
    var processed = this.process(src, grunt.config('NG_VERSION'), config.strict);
    if (styles) {
      processedStyles = this.addStyle(processed, styles.css, styles.minify);
      processed = processedStyles.js;
      if (config.styles.generateCspCssFile) {
        grunt.file.write(removeSuffix(config.dest) + '-csp.css', CSP_CSS_HEADER + processedStyles.css);
      }
    }
    //write
    grunt.file.write(config.dest, processed);
    grunt.log.ok('File ' + config.dest + ' created.');
    fn();

    function removeSuffix(fileName) {
      return fileName.replace(/\.js$/, '');
    }
  },
コード例 #30
0
AbstractVersioner.prototype.saveVersionsMap = function () {
  if (this.options.post) { return; }
  if (typeof this.options.versionsMapFile === "string") {
    var versionsMapContent;

    // Are we generating a json file or are we using a template file?
    var templateFile = this.options.versionsMapTemplate;
    if (typeof templateFile === "string") {
      if (!grunt.file.exists(templateFile)) {

      }
      var template = grunt.util.normalizelf(grunt.file.read(templateFile, 'utf8'));
      versionsMapContent = grunt.template.process(template, {
        data: {
          files: this.versionsMap
        }
      }).replace(/[\n]{2}/g,"\n");
    } else {
      versionsMapContent = JSON.stringify(this.versionsMap);
    }
    grunt.file.write(this.options.versionsMapFile, versionsMapContent);
  }

  grunt.config.set(this.getAssetsVersioningTaskConfigKey() + '.versionsMap', this.versionsMap);
  //var originalTask = grunt.config(this.getAssetsVersioningTaskConfigKey() + '.isPostVersioningTaskFor');
  //if (typeof originalTask === 'string') {
  //  grunt.config.set(originalTask + '.versionsMap', this.versionsMap);
  //}

  if (typeof this.isPostVersioningTask  === 'string') {
    grunt.config.set(this.isPostVersioningTask + '.versionsMap', this.versionsMap);
  }

  grunt.log.debug("Versions Map: ", this.versionsMap);
};