Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Forked from cowboy/grunt-wat.js
Created Apr 25, 2012
Embed
What would you like to do?
I'm not even joking.
// 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 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