How to use the grunt.fail 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 ArnoldZokas / grunt-ssh-multi-exec / test / task option validation.js View on Github external
it('should return validation error', function(next) {
                grunt.fail.fatal = function(error) {
                    expect(error.message).to.equal('child "hosts" fails because ["hosts" is required]');
                    next();
                };

                task.call({
                    async: noop,
                    target: 'test',
                    data: {
                        username: 'test',
                        password: 'test',
                        logFn: noop,
                        commands: [
                            {
                                input: 'echo 1'
                            }
                        ]
github vkadam / grunt-jsbeautifier / test / mode_spec.js View on Github external
afterEach(function() {
        warnMessage = null;
        mockTask = null;
        grunt.fail.warn = oriGruntFailWarn;
        grunt.file.delete("tmp");
    });
github vkadam / grunt-jsbeautifier / test / force_spec.js View on Github external
afterEach(function() {
        warnMessage = null;
        mockTask = null;
        grunt.fail.warn = oriGruntFailWarn;
        grunt.file.delete("tmp");
        grunt.option('force', false);
    });
github MeoMix / StreamusChromeExtension / node_modules / grunt-text-replace / lib / grunt-text-replace.js View on Github external
replace: function (settings) {
    var src = grunt.file.expand(settings.src || []);
    var dest = settings.dest;
    var overwrite = settings.overwrite;
    var replacements = settings.replacements;
    var isDestinationDirectory = (/\/$/).test(dest);
    var initialWarnCount = grunt.fail.warncount;

    if (typeof dest === 'undefined' &&
        typeof src === 'undefined' &&
        typeof replacements === 'undefined') {
      grunt.warn(gruntTextReplace.errorMessages.noTargetsDefined);
    } else if (typeof dest === 'undefined' && overwrite !== true) {
      grunt.warn(gruntTextReplace.errorMessages.noDestination);
    } else if (typeof replacements === 'undefined') {
      grunt.warn(gruntTextReplace.errorMessages.noReplacements);
    } else if (typeof dest !== 'undefined' && overwrite === true) {
      grunt.warn(gruntTextReplace.errorMessages.overwriteFailure);
    } else if ((isDestinationDirectory === false && src.length > 1) && overwrite !== true) {
      grunt.warn(gruntTextReplace.errorMessages.multipleSourceSingleDestination);
    } else if (grunt.fail.warncount - initialWarnCount === 0) {
      gruntTextReplace.replaceFileMultiple({
        src: src,
github rubenv / grunt-git / lib / command_log.js View on Github external
function handleResult(err, result) {
        var logs;

        if (err) {
            grunt.fail.fatal('Error running git log');
            return;
        }

        logs = parseLogs(result.stdout);

        if (options.prop) {
            grunt.config.set(options.prop, logs);
        }

        if (typeof options.callback === 'function') {
            options.callback(logs);
        }
        done();
    }
github maxov / gulp-grunt / index.js View on Github external
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();
      });
    };
github wri / gfw-mapbuilder / 1.1.7 / vendor / pickadate / version-bump.js View on Github external
if (program.patch) {
  bumpVersion('patch')
  return
}

if (program.minor) {
  bumpVersion('minor')
  return
}

if (program.major) {
  bumpVersion('major')
  return
}

grunt.fail.fatal('No release type specified')
return


function bumpVersion(release) {
  grunt.log.writeln('Bumping package version by a ' + release)
  var version = readPackageVersion()
  grunt.log.writeln('Current package version: ' + version)
  version = semver.inc(version, release)
  grunt.log.writeln('Updated package version: ' + version)
  writePackageVersion(version)
  grunt.log.writeln('Done updating the package version')
  updateLibraryFiles(version)
  grunt.log.writeln('Done updating the library files')
}
github thekua / grunt-regex-check / tasks / lib / regex-check.js View on Github external
} else {
                    var filesMessages = matchingFiles.map(function (matchingFile) {
                        var message = name + ': ' + matchingFile.filepath + " - failed because it matched following patterns : ";
                        var prefix = "";
                        matchingFile.matches.forEach(function (element) {
                            message += prefix + "'" + element + "'";
                            prefix = ", "
                        });
                        return message;
                    }).join('\n');
                    var msg = "The following files contained unwanted patterns:\n\n" + filesMessages +
                        "\n\nFiles that were excluded:\n" + excludedFiles.join('\n');
                    if (warnOnly) {
                        log.warn(msg);
                    } else {
                        grunt.fail.warn(msg);
                    }
                }

            });
            if (!ranOnce) {
github vkadam / grunt-jsbeautifier / lib / jsbeautifier.js View on Github external
function getBeautifierSetup(file, config) {
    var fileType = getFileType(file, config),
        jsBeautify = require("js-beautify");
    switch (fileType) {
        case "js":
            return [jsBeautify.js, config.js, addJsNewLine];
        case "css":
            return [jsBeautify.css, config.css];
        case "html":
            return [jsBeautify.html, config.html];
        default:
            grunt.fail.warn("Cannot beautify " + file.cyan + " (only js, css and html files can be beautified)");
            return null;
    }
}
github tapasvimoturu / grunt-code-coverage-enforcer / tasks / lib / code-coverage-enforcer-lib.js View on Github external
if (typeof conf.branches === 'undefined') {
                    conf.branches = branches;
                }
                if (!conf.includes) {
                    conf.includes = includes;
                }
                if (!conf.excludes) {
                    conf.excludes = excludes;
                }
                if (typeof conf.extension) {
                    conf.extension = extension;
                }
                conf.path = exports.normalizeFileName(conf.path);
            });
        } else {
            grunt.fail.error("The config is not in the correct format");
        }
        return configs;
    };