Skip to content

Commit

Permalink
Merged branch master into master
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Aug 16, 2016
2 parents 886c6d6 + 7a5d5de commit 93a54ec
Show file tree
Hide file tree
Showing 5 changed files with 348 additions and 287 deletions.
52 changes: 40 additions & 12 deletions dist/cli/Builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,46 @@ var Builder = function Builder(root, folder, dest, flow) {

this.pathToJson = _.fileUtils.concatPath(root, _.config.data.url);
var files = _.fileAttr.filterLatestVersion(_.FileParser.getFiles(this.pathToJson, _.config.data.url), flow);
files.forEach(function (file) {
var json = _fsExtra2.default.readJsonSync(file.path);
var text = (0, _.getTemplate)(json.abe_meta.template);

_.Util.getDataList(_.fileUtils.removeLast(json.abe_meta.link), text, json).then(function () {
var page = new _.Page(json.abe_meta.link, text, json, true);
(0, _Save.saveHtml)(_.fileUtils.concatPath(root, dest + json.abe_meta.link), page.html);
console.log(_.fileUtils.concatPath(root, dest + json.abe_meta.link));
}).catch(function (e) {
console.error(e);
});
});

if (flow === 'publish') {
files = _.FileParser.getFiles(_.fileUtils.concatPath(root, _.config.publish.url), new RegExp('.' + _.config.files.templates.extension));
// files = FileParser.getMetas(files, 'draft')
}

var build = function build(index) {
var file = files[index];
if (file.path.indexOf('.' + _.config.files.templates.extension) > -1) {
file.path = file.path.replace(_.config.publish.url, _.config.data.url).replace('.' + _.config.files.templates.extension, '.json');

var json = _fsExtra2.default.readJsonSync(file.path);
var text = (0, _.getTemplate)(json.abe_meta.template);

_.Util.getDataList(_.fileUtils.removeLast(json.abe_meta.link), text, json).then(function () {
var page = new _.Page(json.abe_meta.link, text, json, true);
(0, _Save.saveHtml)(_.fileUtils.concatPath(root, dest + json.abe_meta.link), page.html);
console.log(_.fileUtils.concatPath(root, dest + json.abe_meta.link));
if (files[index + 1]) build(index + 1);
}).catch(function (e) {
console.error(e);
if (files[index + 1]) build(index + 1);
});
} else if (file.path.indexOf('.json') > -1) {
var json = _fsExtra2.default.readJsonSync(file.path);
var text = (0, _.getTemplate)(json.abe_meta.template);

_.Util.getDataList(_.fileUtils.removeLast(json.abe_meta.link), text, json).then(function () {
var page = new _.Page(json.abe_meta.link, text, json, true);
(0, _Save.saveHtml)(_.fileUtils.concatPath(root, dest + json.abe_meta.link), page.html);
console.log(_.fileUtils.concatPath(root, dest + json.abe_meta.link));
if (files[index + 1]) build(index + 1);
}).catch(function (e) {
console.error(e);
if (files[index + 1]) build(index + 1);
});
} else if (files[index + 1]) build(index + 1);
};

build(0);
};

if (process.env.ROOT && process.env.FOLDER && process.env.DEST) {
Expand Down
Loading

0 comments on commit 93a54ec

Please sign in to comment.