How to use the fail function from grunt

Find comprehensive JavaScript grunt.fail code examples handpicked from public code repositorys.

2
3
4
5
6
7
8
9
10

module.exports = {
  execSpecsInNode: function() {
    var exit_code = shell.exec("node spec/node_suite.js --color=true").code;
    if (exit_code !== 0) {
      grunt.fail.fatal("Specs Failed", exit_code);
    }
  }
};
fork icon42
star icon317
watch icon20

77
78
79
80
81
82
83
84
85
86
  child.on('close', function (code) {
    if (opt.verbose) {
      grunt.log.ok('[grunt-gulp] Done running Grunt "' + name + '" task.');
    }
    if (code != 0) {
         grunt.fail.warn('[grunt-gulp] Failed running Grunt "' + name + '" task.')
      }
    cb();
  });
};
fork icon22
star icon167
watch icon4

43
44
45
46
47
48
49
50
51
52
var _fn = thisTask.fn;
thisTask.fn = function(arg) {
  // Guaranteed to always be the actual task name.
  var name = thisTask.name;
  // Initialize the errorcount for this task.
  errorcount = grunt.fail.errorcount;
  // Return the number of errors logged during this task.
  Object.defineProperty(this, 'errorCount', {
    enumerable: true,
    get: function() {
fork icon3
star icon0
watch icon0

+ 11 other calls in file

91
92
93
94
95
96
97
98
99
100
  });
  grunt.task.clearQueue();
};

function uncaughtHandler(err) {
  grunt.fail.fatal(err, grunt.fail.code.TASK_FAILURE);
}

grunt.loadTasks = grunt.task.loadTasks = loadTasks.bind(grunt.task, grunt.task.loadTasks);
grunt.loadNpmTasks = grunt.task.loadNpmTasks = loadNpmTasks.bind(grunt.task, grunt.task.loadNpmTasks);
fork icon3
star icon0
watch icon62

+ 5 other calls in file

5
6
7
8
9
10
11
12
13
14
15
16
17
var pkg = require('./package')




var isSuccessful = commitAndTag(pkg.version)
if (!isSuccessful) {
  grunt.fail.fatal('Unable to commit and tag version')
}


return

fork icon0
star icon1
watch icon0

60
61
62
63
64
65
66
67
68
    port ? '--port=' + port : ''
  ]);
  p.stdout.pipe(process.stdout);
  p.stderr.pipe(process.stderr);
  p.on('exit', function(code){
    if(code !== 0) grunt.fail.warn("Karma test(s) failed. Exit code: " + code);
    done();
  });
},
fork icon0
star icon1
watch icon0

180
181
182
183
184
185
186
187
188
189
    grunt.log.writeln(message);
};

warn = function (message) {
    if (config.failIfVulnerabilitiesFound) {
        grunt.fail.warn(message);
    } else {
        log(chalk.red(message));
    }
};
fork icon0
star icon0
watch icon3

+ 15 other calls in file

15
16
17
18
19
20
21
22
23
24


grunt.registerTask('pull_site', 'pulls the files and DB from the remote server', function() {
  var target = grunt.option('target') || task_options['target'];
  if ( typeof target === "undefined" || typeof grunt.config.get('wordpressdeploy')[target] === "undefined" || target === "local")  {
    grunt.fail.warn("Invalid target specified. Did you pass the wrong argument? Please check your task configuration.", 6);
  }

  console.log("pulling site from " + target);
  // Pull database
fork icon0
star icon0
watch icon1

158
159
160
161
162
163
164
165
166
167
      '--source_map_format=V3 ' +
      '--create_source_map ' + mapFile + ' ' +
      '--js ' + file + ' ' +
      '--js_output_file ' + minFile,
function(code) {
  if (code !== 0) grunt.fail.warn('Error minifying ' + file);

  // closure creates the source map relative to build/ folder, we need to strip those references
  grunt.file.write(mapFile, grunt.file.read(mapFile).replace('"file":"build/', '"file":"').
                                                     replace('"sources":["build/','"sources":["'));
fork icon0
star icon0
watch icon5

+ 3 other calls in file