Skip to content

Instantly share code, notes, and snippets.

@0x230c40a9b133aa
Created July 12, 2017 12:24
Show Gist options
  • Select an option

  • Save 0x230c40a9b133aa/56a046d32782e082715ee3f799c7428d to your computer and use it in GitHub Desktop.

Select an option

Save 0x230c40a9b133aa/56a046d32782e082715ee3f799c7428d to your computer and use it in GitHub Desktop.

Revisions

  1. 0x230c40a9b133aa created this gist Jul 12, 2017.
    28 changes: 28 additions & 0 deletions export.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    /*
    (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}`);
    });
    });
    });
    });