forked from openstreetmap/iD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_css.js
56 lines (45 loc) · 1.14 KB
/
build_css.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* eslint-disable no-console */
const colors = require('colors/safe');
const concat = require('concat-files');
const glob = require('glob');
let _currBuild = null;
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;