forked from stefanpenner/es6-promise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Brocfile.js
65 lines (53 loc) · 1.81 KB
/
Brocfile.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
65
/* jshint node:true, undef:true, unused:true */
var compileModules = require('broccoli-es6-module-transpiler');
var merge = require('broccoli-merge-trees');
var uglify = require('broccoli-uglify-js');
var version = require('git-repo-version');
var browserify = require('broccoli-watchify');
var fs = require('fs');
var stew = require('broccoli-stew');
var find = stew.find;
var mv = stew.mv;
var rename = stew.rename;
var env = stew.env;
var map = stew.map;
var lib = find('lib');
var testDir = find('test');
var testFiles = find('test/{index.html,worker.js}');
var json3 = mv(find('node_modules/json3/lib/{json3.js}'), 'node_modules/json3/lib/', 'test/');
var mocha = mv(find('node_modules/mocha/mocha.{js,css}'), 'node_modules/mocha/', 'test/');
var testVendor = merge([ json3, mocha ]);
var es6Promise = compileModules(lib, {
format: 'bundle',
entry: 'es6-promise.umd.js',
output: 'es6-promise.js'
});
var testBundle = browserify(merge([
mv(es6Promise, 'test'),
testDir
]), {
browserify: { entries: ['./test/index.js'] },
init: function (b) { b.external('vertx'); }
});
var dist = es6Promise;
env('production', function() {
dist = merge([
rename(uglify(dist), '.js', '.min.js'),
dist
]);
});
function prependLicense(content) {
var license = fs.readFileSync('./config/versionTemplate.txt').toString().replace(/VERSION_PLACEHOLDER_STRING/, version());
// strip source maps for now...
var content = content.replace(/\/\/# sourceMappingURL=es6-promise.*/,'');
return license + '\n' + content;
}
// exclude source maps for now, until map/cat supports source maps
dist = find(dist, '!*.map');
module.exports = merge([
map(dist, prependLicense),
testFiles,
testVendor,
mv(dist, 'test'),
mv(testBundle, 'test')
]);