Created
November 15, 2012 20:58
-
-
Save bmatusiak/4081220 to your computer and use it in GitHub Desktop.
requirejs wrapper for file directory in / out
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
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