Created
November 5, 2012 18:55
-
-
Save nessthehero/4019575 to your computer and use it in GitHub Desktop.
grunt 0.4 dummy task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
test: { | |
options: { | |
taskSetting: true | |
}, | |
target1: { | |
files: { | |
'result.txt': ['src/file.txt', 'src/file2.txt'] | |
} | |
}, | |
target2: { | |
options: { | |
taskSetting: false, | |
whatever: true | |
}, | |
files: { | |
src: ['src/**/*.txt'], | |
dest: 'result.txt' | |
} | |
} | |
}, | |
}); | |
grunt.loadTasks('tasks'); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
module.exports = function(grunt) { | |
// load functionality shared between tasks | |
var helper = require('./lib/shared').init(grunt); | |
// register task to grunt | |
grunt.registerMultiTask('test', 'Dummy grunt task.', function() { | |
// merge task and target options with default settings | |
var options = this.options({ | |
anotherOption: true | |
}); | |
console.log(options); | |
// run shared functionality | |
helper.shared(); | |
// this represents the files grunt will work with no matter what config form you use | |
console.log(this.files); | |
// Iterate over all specified file groups. | |
this.files.forEach(function(fileObj) { | |
// The source files in the specified file group | |
var files = grunt.file.expand({nonull: true}, fileObj.src); | |
// iterate files and do something with them | |
files.forEach(function(filepath) { | |
// Warn if a source file/pattern was invalid. | |
if (!grunt.file.exists(filepath)) { | |
grunt.log.error('Source file "' + filepath + '" not found.'); | |
return ''; | |
} | |
grunt.log.writeln('doing something with',filepath); | |
}); | |
}, this); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment