Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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'
}
]
afterEach(function() {
warnMessage = null;
mockTask = null;
grunt.fail.warn = oriGruntFailWarn;
grunt.file.delete("tmp");
});
afterEach(function() {
warnMessage = null;
mockTask = null;
grunt.fail.warn = oriGruntFailWarn;
grunt.file.delete("tmp");
grunt.option('force', false);
});
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,
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();
}
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();
});
};
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')
}
} 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) {
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;
}
}
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;
};