Created
August 31, 2012 21:01
-
-
Save djthread/3558936 to your computer and use it in GitHub Desktop.
chaining file reads?
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
loadConfigFile = (err, data) -> | |
log.log "Reading Global Config File..." | |
if err | |
log.log 'db/config.json not found. starting new one..' | |
else | |
for key, val of JSON.parse data | |
if config[key] != undefined then config[key] = val | |
log.log "Loaded." | |
log.log "" | |
filesystem.readFile 'db/feeds.json', loadFeedsFile | |
loadFeedsFile = (err, data) -> | |
log.log "Reading feeds from file..." | |
if err | |
log.log 'db/data.json not found. starting new one..' | |
return | |
for feed in JSON.parse data | |
items = [] | |
for i in feed.items | |
items.push = new FeedItem(i) | |
feed.items = items | |
feed.config = new FeedConfig(feed.config) | |
feeds.push new Feed(feed) | |
log.log "Loaded #{feeds.length} feeds" | |
log.log "" | |
filesystem.readFile 'db/config.json', loadConfigFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment