Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// parse error
grunt.log.error(chalk.red('Parser error') + (err.filename ? ' in ' + chalk.yellow(err.filename) : '') + '\n');
} else {
// other exception
grunt.log.error((err.name ? chalk.red(err.name) + ': ' : '') + err.message +
(err.filename ? ' in ' + chalk.yellow(err.filename) : '') + '\n');
}
// if extract - then log it
if (err.extract) {
err.extract.forEach(function (line, index) {
grunt.log.error(padLine(err.line + index) + line);
});
}
grunt.warn('');
};
data.forEach(function (item) {
if (item.options.compile || reporter) {
min.push(item.output);
max.push(item.data);
// Extract status and check
} else if (item.output[1] && item.output[1].indexOf('Perfect!') !== -1) {
grunt.log.writeln(item.output.join('\n'));
} else {
grunt.warn(item.output.join('\n'));
}
if (reporter) {
reporter.inst.startFile(dest);
if (item.definitions && item.definitions.length) {
// loop over definitions to get errors
item.definitions.forEach(function (definition) {
if (definition.errors && definition.errors.length) {
definition.errors.forEach(function (definitionErr) {
// report that error
reporter.inst.logError(definitionErr);
});
}
});
}
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,
dest: dest,
replacements: replacements
});
}
},
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,
dest: dest,
replacements: replacements
});
}
},
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,
dest: dest,
replacements: replacements
});
}
},
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,
dest: dest,
replacements: replacements
});
}
},
grunt.registerTask('hello', 'greeting task', function(name) {
if(!name || !name.length) {
grunt.warn('you need to provide a name');
}
console.log('hello ' + name + '!');
});
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,
dest: dest,
replacements: replacements
});
}
},
grunt.registerTask('validateandruntask', 'if task available then run given task', function(taskname) {
if(!taskname || !taskname.length) {
grunt.warn('task name is needed to run this task');
}
if(!grunt.task.exists(taskname)) {
grunt.log.writeln('this task does not exist!');
} else {
grunt.log.writeln(taskname + ' exists. Going to run this task');
grunt.task.run(taskname);
}
});
version: function(version) {
var current = [version.major, version.minor, version.patch].join('.');
var required = '>= 1.6.0';
if (!semver.satisfies(current, required)) {
halt();
grunt.log.writeln();
grunt.log.errorlns(
'In order for this task to work properly, PhantomJS version ' +
required + ' must be installed, but version ' + current +
' was detected.'
);
grunt.warn('The correct version of PhantomJS needs to be installed.', 127);
}
}
};