How to use the grunt.task function in grunt

To help you get started, we’ve selected a few grunt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rehabstudio / fe-skeleton / run / tasks / styles / grunt.js View on Github external
// Generate paths for this row.
        var destPath = globalSettings.destPath + common.outputFolder + thisBundle.fileName + '.css',
            sourcePath = thisBundle.srcPath + thisBundle.fileName + '.scss',
            buildObject = {};

        // Apply the generated dest / source paths to the build object.
        buildObject.files = {};
        buildObject.files[destPath] = sourcePath;

        // Apply this specific build configuration to the overall SASS settings.
        grunt.config.set('sass.' + uniqueBuildKey, buildObject);
    }

    // Compile SASS into CSS then prefix and save.
    grunt.task.run(['sass', 'autoprefixer']);
});
github maxov / gulp-grunt / index.js View on Github external
var getTasks = module.exports.tasks = function (options) {
  var opt = makeOptions(options);

  var oldCwd = process.cwd();
  var cwd = opt.base != null ? opt.base : oldCwd;

  grunt.file.setBase(cwd);

  var gruntCliDir = opt.base ? (opt.base + "/") : "";

  grunt.task.init([]);

  process.chdir(oldCwd);

  var gruntTasks = grunt.task._tasks,
    finalTasks = {};

  var registerGruntTask = function (name) {
    finalTasks[opt.prefix + name] = function (cb) {
      if (opt.verbose) {
        console.log('[grunt-gulp] Running Grunt "' + name + '" task...');
      }
      var args = opt.force ?  [name, '--force', '--verbose=' + opt.verbose] : [name, '--verbose=' + opt.verbose];
      for (var key in opt) {
        if (key != 'base' && key != 'prefix') {
          args = args.concat('--' + key + '=' + opt[key]);
        }
github dhategan / brackets-grunt / node / GruntDomain.js View on Github external
function runTaskDirect(task, path, callback) {
        //reload grunt module
		require.uncache('grunt');
		var grunt = require("grunt");
        grunt.option('gruntfile', getGruntfilePath(path));
		grunt.option('verbose', "true");
		grunt.task.init([]);
        grunt.task.run(task);
		grunt.task.start();
    }
github spmjs / spm / lib / sdk / grunt.js View on Github external
function runCli(name, gruntfile) {
  var fn;
  if (typeof gruntfile === 'function') {
    fn = gruntfile;
  } else {
    fn = require(path.resolve(gruntfile));
  }
  if (typeof fn === 'function') {
    fn.call(grunt, grunt);
    if (grunt.task._tasks[name]) {
      grunt.option('gruntfile', gruntfile);
      grunt.option('base', process.cwd());

      var task = grunt.task;
      var fail = grunt.fail;

      var uncaughtHandler = function(e) {
        fail.fatal(e, fail.code.TASK_FAILURE);
      };
      process.on('uncaughtException', uncaughtHandler);

      task.options({
        error: function(e) {
          fail.warn(e, fail.code.TASK_FAILURE);
        },
        done: function() {
          process.removeListener('uncaughtException', uncaughtHandler);
          fail.report();
          process.exit(0);
        }
github yoniholmes / grunt-text-replace / lib / grunt-text-replace.js View on Github external
processGruntTemplate: function (string) {
    var isProcessTemplateTrue = true;
    if (grunt.task.current.data &&
        grunt.task.current.data.options &&
        typeof grunt.task.current.data.options.processTemplates !== 'undefined' &&
        grunt.task.current.data.options.processTemplates === false) {
      isProcessTemplateTrue = false;
    }
    return isProcessTemplateTrue ? grunt.template.process(string) : string;
  }
github jasmine-contrib / grunt-jasmine-task / tasks / jasmine.js View on Github external
task.phantomRunner = function(options,cb){
  options = grunt.util._.extend({},defaultOptions,options);

  var phantomReporters = [
      grunt.task.getFile('jasmine/reporters/ConsoleReporter.js'),
      grunt.task.getFile('jasmine/reporters/JUnitReporter.js')
    ],
    port = (options.server && options.server.port) || 8888;

  var url = URL.format({
    protocol : 'http',
    hostname : '127.0.0.1',
    port : port + '',
    pathname : path.join(baseDir,tmpRunner)
  });

  grunt.verbose.subhead('Testing jasmine specs via phantom').or.writeln('Testing jasmine specs via phantom');
  jasmine.buildSpecrunner(baseDir, options, phantomReporters);
  var server = startServer(baseDir, port);

  runPhantom(url,options,phantomReporters.length,function(err,status){
github rehabstudio / fe-skeleton / run / tasks / images / grunt.js View on Github external
grunt.registerTask('images', function() {
    grunt.task.run(['imagemin', 'svgmin']);
});
github yapplabs / glazier / configurations / watch.js View on Github external
function copyCards(value){
  grunt.task.run('copy:cards');
  return value;
}
github rehabstudio / fe-skeleton / run / tasks / build / grunt.js View on Github external
grunt.registerTask('build', function() {
    grunt.task.run(['styles', 'scripts', 'moveAssets']);
});