Skip to content

Commit

Permalink
Merge pull request #12 from bonkles-worldai/v3_merge
Browse files Browse the repository at this point in the history
Merge master with latest v3 code from upstream.
  • Loading branch information
Bonkles committed Dec 4, 2019
2 parents 99152ab + 00209de commit 07a8e92
Show file tree
Hide file tree
Showing 406 changed files with 6,266 additions and 10,818 deletions.
4,007 changes: 0 additions & 4,007 deletions CHANGELOG.md

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const buildData = require('./build_data');
const buildSrc = require('./build_src');
const buildCSS = require('./build_css');

let _currBuild = null;

// if called directly, do the thing.
buildAll();


function buildAll() {
if (_currBuild) return _currBuild;

return _currBuild =
Promise.resolve()
.then(() => buildCSS())
.then(() => buildData())
.then(() => buildSrc())
.then(() => _currBuild = null)
.catch((err) => {
console.error(err);
_currBuild = null;
process.exit(1);
});
}

module.exports = buildAll;
78 changes: 48 additions & 30 deletions build_css.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,54 @@ const colors = require('colors/safe');
const concat = require('concat-files');
const glob = require('glob');

let _currBuild = null;

module.exports = function buildCSS() {
var isBuilding = false;
return function () {
if (isBuilding) return;

console.log('building css');
console.time(colors.green('css built'));
isBuilding = true;

return concatFilesProm('css/**/*.css', 'dist/iD.css')
.then(function () {
console.timeEnd(colors.green('css built'));
isBuilding = false;
})
.catch(function (err) {
console.error(err);
process.exit(1);
});
};
};

function concatFilesProm(globPath, output) {
return new Promise(function (res, rej) {
glob(globPath, function (er, files) {
if (er) return rej(er);
concat(files, output, function (err) {
if (err) return rej(err);
res();
});
});

function buildCSS() {
if (_currBuild) return _currBuild;

const START = '🏗 ' + colors.yellow('Building css...');
const END = '👍 ' + colors.green('css built');

console.log('');
console.log(START);
console.time(END);

return _currBuild =
Promise.resolve()
.then(() => doGlob('css/**/*.css'))
.then((files) => doConcat(files, 'dist/iD.css'))
.then(() => {
console.timeEnd(END);
console.log('');
_currBuild = null;
})
.catch((err) => {
console.error(err);
console.log('');
_currBuild = null;
process.exit(1);
});
}


function doGlob(pattern) {
return new Promise((resolve, reject) => {
glob(pattern, (err, files) => {
if (err) return reject(err);
resolve(files);
});
});
}

function doConcat(files, output) {
return new Promise((resolve, reject) => {
concat(files, output, (err) => {
if (err) return reject(err);
resolve();
});
});
}


module.exports = buildCSS;
Loading

0 comments on commit 07a8e92

Please sign in to comment.