Skip to content

Commit

Permalink
feat(agent-website): generate all HTML at start when some are missing
Browse files Browse the repository at this point in the history
Close #47
  • Loading branch information
XavierBoubert committed Nov 2, 2014
1 parent 4863736 commit 45bf78b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions the-machine/features/agent-website/agent-website.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,48 @@

_work('all');
});

_checkWebsiteVersion();
}

function _checkWebsiteVersion() {
var missingFiles = [],
firstTime = true;

glob.sync(PATHS.WEBSITE_EJS).map(function(file) {
var source = path.resolve(file),
dir = path.dirname(source),
fileHTML = path.basename(source.replace('.ejs', '.html'));

if(source.indexOf(path.sep + 'features' + path.sep) > -1) {
return;
}

for(var langIndex = 0, langLength = LANGS.DIRECTORIES.length; langIndex < langLength; langIndex++) {
var lang = LANGS.DIRECTORIES[langIndex],
subdir = lang == LANGS.INDEX ? '.' : lang,
dirHTML = path.join(dir, subdir, fileHTML);

if(!fs.existsSync(dirHTML)) {
missingFiles.push(dirHTML);
}
else {
firstTime = false;
}
}

});

if(missingFiles.length > 0) {
var message = firstTime ?
'Boss I think the website has been generated. I have to regenerate all the HTML files.' :
'Mmm something\'s wrong with the website, ' + missingFiles.length + ' HTML files are missing. I have to regenerate them.';

_this.newDiscussion();
_this.says(message);

_work('all');
}
}

function _work(type, ejsFile, folder) {
Expand Down

0 comments on commit 45bf78b

Please sign in to comment.