diff --git a/helper/tools/get-static.js b/helper/tools/get-static.js new file mode 100644 index 0000000..c2829dd --- /dev/null +++ b/helper/tools/get-static.js @@ -0,0 +1,45 @@ +var fs = require('fs'), +path = require('path'); + +var getAllFiles = function (root){ + var res = [], + files = fs.readdirSync(root); + + files.forEach(function(file){ + var pathname = root+'/'+file, + stat = fs.lstatSync(pathname); + + if (!stat.isDirectory()){ + if (file.indexOf(".ftl") < 0 && file.indexOf(".properties") < 0 + && root.indexOf("../../helper") < 0 && root.indexOf("../../.git") < 0) { + res.push(pathname); + } + } else { + res = res.concat(getAllFiles(pathname)); + } + }); + return res; +}; + +var mkdirsSync = function(dirpath) { + if(fs.existsSync(dirpath)){ + return; + } + var dirs = dirpath.split('/'); + var dir = ''; + for(var i = 0; i < dirs.length; i++) { + dir += dirs[i] + '/'; + if(!fs.existsSync(dir)){ + fs.mkdirSync(dir); + } + } +}; + +var skins = getAllFiles("../.."); +(function () { + mkdirsSync("static"); + for (var i = 0; i < skins.length; i++) { + mkdirsSync(path.dirname(skins[i].replace("../..", "static"))); + fs.writeFileSync(skins[i].replace("../..", "static"), fs.readFileSync(skins[i]), "UTF-8"); + } +})(); \ No newline at end of file