Skip to content

Instantly share code, notes, and snippets.

@Pupix
Last active August 30, 2016 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pupix/a2c8cc31ae78544a3a28cea5fa13ccce to your computer and use it in GitHub Desktop.
Save Pupix/a2c8cc31ae78544a3a28cea5fa13ccce to your computer and use it in GitHub Desktop.
.inibin to .json converter
/**
* 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);
});
{
"name": "inibin-converter",
"version": "0.0.1",
"description": "",
"main": "index.js",
"author": "Pupix <manolea.robert@gmail.com>",
"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