Skip to content

Instantly share code, notes, and snippets.

@bmatusiak
Created November 15, 2012 20:58
Show Gist options
  • Save bmatusiak/4081220 to your computer and use it in GitHub Desktop.
Save bmatusiak/4081220 to your computer and use it in GitHub Desktop.
requirejs wrapper for file directory in / out
var fs = require("fs");
var inPath = __dirname + "/in";
var outPath = __dirname + "/out";
fs.readdir(inPath, function(err, files) {
if (err) throw err;
for (var i in files) {
fs.readFile(inPath + "/" +files[i], doWrap(files[i]));
}
});
function doWrap(file) {
return function(err, data) {
if (err) throw err;
fs.writeFile(outPath+"/"+file,'define(function(require, exports, module) { ' + data + ' });' , function(err) {
if (err) throw err;
console.log(file+' saved!');
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment