-
-
Save mahemoff/2484757 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. | |
// v0.0.0.2 Robust version with namespacing | |
module.exports = function(grunt) { | |
//Grunt Globals | |
com.wtfjs.constants = new Array(); | |
com.wtfjs.constants.ConcatOutputFileNameAndLocation="c:\\TestOutput.js"; | |
com.wtfjs.constants.JavascriptDirectory = 'C:\\Work\\Patch29\\StaticContent\\RootAssets\\JsLib' | |
com.wtfjs.constants.MessageTaskStart = "StartingTask_"; | |
com.wtfjs.constants.MessageTaskEnd = "EndingTask_"; | |
com.wtfjs.constants.MessageTaskERR = "Error_"; | |
com.wtfjs.constants.MessageTaskReturnObjectValue = "ReturnObjectValue_"; | |
var arryOfFiles = new Array(); | |
var stringOfFiles; | |
//Grunt Functions | |
function readFiles() | |
{ | |
var tmparry = new Array(); | |
console.log(com.wtfjs.constants.MessageTaskStart + 'readFiles()'); | |
var fs = require('fs'); | |
tmparry = fs.readdirSync(com.wtfjs.constants.JavascriptDirectory).filter(function(file) { return file.substr(-3) == '.js'}); | |
tmparry.forEach(function(item) | |
{ | |
arryOfFiles.push("'" + com.wtfjs.constants.JavascriptDirectory + item + "'"); | |
}); | |
console.log(com.wtfjs.constants.MessageTaskEnd + 'readFiles()'); | |
//console.log(com.wtfjs.constants.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:com.wtfjs.constants.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'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment