Created
July 12, 2017 12:24
-
-
Save 0x230c40a9b133aa/56a046d32782e082715ee3f799c7428d to your computer and use it in GitHub Desktop.
A handy script that extracts hermit name and the advancement title in HermitCraft Advancement pack
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
/* | |
(c) 0x230c40a9b133aa 2017, Licensed under MIT. | |
Usage: put file in advancements/hermitcraft/-directory, run with `node export.js` | |
Note: The output separates the hermit name and the advancement title with a tab ('\t'), so you can just copy and paste them in to a spreadsheet program (i.e. MS Excel) and the program will automatically put the hermit names and the advancement titles in their own columns! | |
*/ | |
const fs = require('fs'); | |
const path = require('path'); | |
fs.readdir(__dirname, (err, dirs) => { | |
if (err) throw err; | |
dirs.filter(dir => dir.indexOf('.') === -1).forEach((dirName) => { | |
let hermit; | |
try { | |
hermit = require(path.join(__dirname, dirName, 'root.json')).display.title.text; | |
} catch(e) { | |
hermit = dirName; | |
} | |
fs.readdir(path.join(__dirname, dirName), (fErr, files) => { | |
if (fErr) throw fErr; | |
files.filter(file => !file.startsWith('.')).filter(file => file.indexOf('_check') === -1 && file.indexOf('_trigger') === -1 && file !== 'root.json').forEach((file) => { | |
const advancement = require(path.join(__dirname, dirName, file)); | |
console.log(`${hermit}\t${advancement.display.title.text}`); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment