Add grunt.log.warn method

This commit is contained in:
martinmcwhorter
2014-08-04 01:21:54 +01:00
parent 00124520f7
commit 24df639f25
2 changed files with 48 additions and 0 deletions
+43
View File
@@ -73,3 +73,46 @@ exports = (grunt: IGrunt) => {
fileMaps[0].src.length;
fileMaps[0].dest;
};
// Official grunt task template from
// https://github.com/gruntjs/grunt-init-gruntplugin/blob/master/root/tasks/name.js
exports.exports = function(grunt: IGrunt) {
// Please see the Grunt documentation for more information regarding task
// creation: http://gruntjs.com/creating-tasks
grunt.registerMultiTask('taskName', 'task description', function() {
// Merge task-specific and/or target-specific options with these defaults.
var options = this.options({
punctuation: '.',
separator: ', '
});
// Iterate over all specified file groups.
this.files.forEach(function(f) {
// Concat specified files.
var src = f.src.filter(function(filepath) {
// Warn on and remove invalid source files (if nonull was set).
if (!grunt.file.exists(filepath)) {
grunt.log.warn('Source file "' + filepath + '" not found.');
return false;
} else {
return true;
}
}).map(function(filepath) {
// Read file source.
return grunt.file.read(filepath);
}).join(grunt.util.normalizelf(options.separator));
// Handle options.
src += options.punctuation;
// Write the destination file.
grunt.file.write(f.dest, src);
// Print a success message.
grunt.log.writeln('File "' + f.dest + '" created.');
});
});
};
+5
View File
@@ -690,6 +690,11 @@ declare module grunt {
* Log a list of obj properties (good for debugging flags).
*/
writeflags(obj: any): T
/**
* Log an warning with grunt.log.warn
*/
warn(msg: string): T
}
/**