forked from fabricjs/fabric.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_build_script.js
64 lines (55 loc) · 1.34 KB
/
create_build_script.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
57
58
59
60
61
62
63
64
var fs = require('fs'),
//execSync = require('execSync').exec;
execSync = require('child_process').execSync;
var modules = [
'text',
'itext',
'textbox',
'animation',
'gestures',
'easing',
'parser',
'freedrawing',
'interaction',
'serialization',
'image_filters',
'gradient',
'pattern',
'shadow',
'node'
];
// http://stackoverflow.com/questions/5752002/find-all-possible-subset-combos-in-an-array
var combine = function(a, min) {
var fn = function(n, src, got, all) {
if (n === 0) {
if (got.length > 0) {
all[all.length] = got;
}
return;
}
for (var j = 0, len = src.length; j < len; j++) {
fn(n - 1, src.slice(j + 1), got.concat([src[j]]), all);
}
return;
};
var all = [];
for (var i = min, _len = a.length; i < _len; i++) {
fn(i, a, [], all);
}
all.push(a);
return all;
};
var combinations = combine(modules, 1);
var startTime = new Date;
fs.writeFile('build.sh', '#!/usr/bin/env sh\n\n', function() {
for (var i = 0, len = combinations.length; i < len; i++) {
var modulesStr = combinations[i].join(',');
var command = 'node build.js build-sh modules=' + modulesStr;
execSync(command);
if (i % 100 === 0) {
console.log(i + '/' + len);
}
}
// create basic (minimal) build
execSync('node build.js build-sh modules=');
});