Last active
August 30, 2016 23:14
-
-
Save Pupix/a2c8cc31ae78544a3a28cea5fa13ccce to your computer and use it in GitHub Desktop.
.inibin to .json converter
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 characters
/** | |
* Converts `.inibin` fiiles to `.json`. | |
* | |
* Usage example: | |
* Create an `inibins` directory and put your `.inibin` files in there | |
* Run `node index` from terminal and a new directory `extracted` will | |
* be created, with the extracted files | |
* | |
*/ | |
// PATHS | |
const INIBIN_PATH = './inibins'; | |
const OUTPUT_PATH = './extracted'; | |
// MODULES | |
const Inibin = require('lol-inibin-parser'); | |
const async = require('async'); | |
const fs = require('fs-extra'); | |
const path = require('path'); | |
// FILE LIST | |
const files = fs.readdirSync(INIBIN_PATH); | |
// Extract files in series so we don't kill the disk πππ | |
async.eachSeries(files, (file, callback) => { | |
const inibin = new Inibin(); | |
const entryPath = path.join(INIBIN_PATH, file); | |
const outPath = path.join(OUTPUT_PATH, file.replace(/\.inibin$/, '.json')); | |
console.log(`Extracting: ${file}`); | |
async.waterfall([ | |
(next) => inibin.read(entryPath, next), | |
(data, next) => fs.outputJSON(outPath, data, next) | |
], callback); | |
}, err => { | |
console.log(err || `Y'are done`); | |
process.exit(0); | |
}); |
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 characters
{ | |
"name": "inibin-converter", | |
"version": "0.0.1", | |
"description": "", | |
"main": "index.js", | |
"author": "Pupix <[email protected]>", | |
"license": "MIT", | |
"dependencies": { | |
"async": "^2.0.1", | |
"fs-extra": "^0.30.0", | |
"lol-inibin-parser": "^0.9.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment