Last active
January 30, 2019 01:37
-
-
Save cannalee90/e0f5554e79bf473f1bd253fb004783ec to your computer and use it in GitHub Desktop.
Revisions
-
cannalee90 revised this gist
Jan 23, 2019 . 1 changed file with 9 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ // $ node keyreplace.js MISSION:320010 const fs = require('fs'); const path = require('path'); @@ -29,8 +31,8 @@ fromfileList.forEach((dataFilePath) => { const filename = tmp[tmp.length -1]; const code = filename.split('_')[1] const data = fs.readFileSync(dataFilePath, {encoding: 'utf8'}); const targetfilePath = targetfileList.filter((file) => { return file.indexOf(code) !== -1; })[0]; @@ -39,12 +41,15 @@ fromfileList.forEach((dataFilePath) => { return; }; const target = fs.readFileSync(targetfilePath, { encoding: 'utf8' }); json = JSON.parse(data.trim()); targetJson = JSON.parse(target.trim()); console.log(`from ${dataFilePath} to ${targetfilePath}`); console.log(`from ${targetJson[targetKey]} to ${json[targetKey]}`); targetJson[targetKey] = json[targetKey]; fs.writeFileSync(targetfilePath, JSON.stringify(targetJson, null, 4), { encoding: 'utf8' }); }) -
cannalee90 created this gist
Jan 23, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ const fs = require('fs'); const path = require('path'); const args = process.argv.slice(2); const targetKey = args[0]; if (!targetKey) { console.log('Please ADD Key for Data'); process.exit(1); } const from = 'C:/Users/kangho/PUBG/game-design-data/localization/mission'; const target = 'C:/Users/kangho/PUBG/Tsl_server/Source/src/Bro/BroApp2/src/app/_lib/Bro/translation/data'; const getFileList = (dir) => { return fs.readdirSync(dir).reduce(function(list, file) { const name = path.join(dir, file); const isDir = fs.statSync(name).isDirectory(); return list.concat(isDir ? getFileList(name) : [name]); }, []); } const fromfileList = getFileList(from); const targetfileList = getFileList(target); fromfileList.forEach((dataFilePath) => { const tmp = dataFilePath.split('\\'); const filename = tmp[tmp.length -1]; const code = filename.split('_')[1] let data = fs.readFileSync(dataFilePath, {encoding: 'utf8'}); let targetfilePath = targetfileList.filter((file) => { return file.indexOf(code) !== -1; })[0]; if (!targetfilePath) { console.log(`There is not ${filename} in Broapp`); return; }; let target = fs.readFileSync(targetfilePath, { encoding: 'utf8' }); json = JSON.parse(data.trim()); targetJson = JSON.parse(target.trim()); targetJson[targetKey] = json[targetKey]; fs.writeFileSync(targetfilePath, JSON.stringify(targetJson, null, 4), { encoding: 'utf8' }); })