Created
April 18, 2012 19:00
-
-
Save cowboy/2415785 to your computer and use it in GitHub Desktop.
I'm not even joking.
This file contains 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
// This was what I got, pasted into an email. | |
module.exports = function(grunt) { | |
//Grunt Globals | |
var ConcatOutputFileNameAndLocation="c:\\TestOutput.js"; | |
var JavascriptDirectory = 'C:\\Work\\Patch29\\StaticContent\\RootAssets\\JsLib' | |
var MessageTaskStart = "StartingTask_"; | |
var MessageTaskEnd = "EndingTask_"; | |
var MessageTaskERR = "Error_"; | |
var MessageTaskReturnObjectValue = "ReturnObjectValue_"; | |
var arryOfFiles = new Array(); | |
var stringOfFiles; | |
//Grunt Functions | |
function readFiles() | |
{ | |
var tmparry = new Array(); | |
console.log(MessageTaskStart + 'readFiles()'); | |
var fs = require('fs'); | |
tmparry = fs.readdirSync(JavascriptDirectory).filter(function(file) { return file.substr(-3) == '.js'}); | |
tmparry.forEach(function(item) | |
{ | |
arryOfFiles.push("'" + JavascriptDirectory + item + "'"); | |
}); | |
console.log(MessageTaskEnd + 'readFiles()'); | |
//console.log(MessageTaskReturnObjectValue + arryOfFiles); | |
//console.log(arryOfFiles.toString()); | |
stringOfFiles = arryOfFiles.toString(); | |
return true; | |
} | |
//Grunt Tasks | |
grunt.registerInitTask('ReadFiles','Read Files',function() {var done = this.async(); done(readFiles()); }); | |
//Grunt Commands | |
grunt.task.run('ReadFiles'); | |
grunt.registerTask('ReadFiles','ReadFiles',readFiles()); | |
grunt.registerTask('default', 'concat'); | |
//Grunt Init | |
grunt.initConfig( | |
{ | |
concat: { | |
dist: { | |
src: [stringOfFiles], | |
dest:ConcatOutputFileNameAndLocation | |
} | |
} | |
}); | |
}; |
This file contains 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
// This is probably how it should've been done. | |
module.exports = function(grunt) { | |
// Grunt Init | |
grunt.initConfig({ | |
concat: { | |
dist: { | |
src: ['StaticContent/RootAssets/JsLib/**/*.js'], | |
dest: 'TestOutput.js' | |
} | |
} | |
}); | |
// Grunt Tasks | |
grunt.registerTask('default', 'concat'); | |
}; |
lol. Someone has not heard of globbing or read the docs.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I love seeing new Array() in JavaScript it reminds me of Java :)