Created
January 24, 2015 23:37
-
-
Save silentrob/61d3c0596afe89afb8b4 to your computer and use it in GitHub Desktop.
Creating a boot file for a superscript bot
This file contains 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
var facts = require("sfacts"); | |
var fs = require("fs"); | |
var worldData = [ | |
'./data/concepts.top', | |
'./data/names.top', | |
'./data/oppisite.tbl', | |
'./data/worlddata/animals.tbl', | |
'./data/worlddata/color.tbl' | |
]; | |
facts.load(worldData, "britfacts", function(err, res){ | |
var parse = require("superscript/lib/parse")(res); | |
var exists = fs.existsSync('./data.json'); | |
var contents = {}; | |
var sums = {}; | |
if (exists) { | |
contents = fs.readFileSync('./data.json', 'utf-8'); | |
contents = JSON.parse(contents); | |
sums = contents.checksums; | |
} | |
parse.loadDirectory('./topics', sums, function(err, result) { | |
parse.merge(contents, result, function(err, results) { | |
fs.writeFile('./data.json', JSON.stringify(results), function (err) { | |
console.log("Loaded"); | |
}); | |
}); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment