X Tutup
Skip to content

Commit 1eab4f5

Browse files
zzoalexeagle
authored andcommitted
feat(license): include license files in dev and dev.sfx bundles
1 parent cf103de commit 1eab4f5

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

gulpfile.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var madge = require('madge');
1616
var merge = require('merge');
1717
var merge2 = require('merge2');
1818
var path = require('path');
19+
var licenseWrap = require('./tools/build/licensewrap');
1920

2021
var watch = require('./tools/build/watch');
2122

@@ -951,20 +952,37 @@ gulp.task('bundle.js.min.deps', ['bundle.js.min'], function() {
951952
});
952953

953954
var JS_DEV_DEPS = [
955+
licenseWrap('node_modules/zone.js/LICENSE', true),
954956
'node_modules/zone.js/dist/zone-microtask.js',
955957
'node_modules/zone.js/dist/long-stack-trace-zone.js',
956-
'node_modules/reflect-metadata/Reflect.js'
958+
licenseWrap('node_modules/reflect-metadata/LICENSE', true),
959+
'node_modules/reflect-metadata/Reflect.js',
960+
// traceur-runtime is always first in the bundle
961+
licenseWrap('node_modules/traceur/LICENSE', true)
957962
];
958963

964+
// Splice in RX license if rx is in the bundle.
965+
function insertRXLicense(source) {
966+
var n = source.indexOf('System.register("rx"');
967+
if (n >= 0) {
968+
var rxLicense = licenseWrap('node_modules/rx/license.txt');
969+
return source.slice(0, n) + rxLicense + source.slice(n);
970+
} else {
971+
return source;
972+
}
973+
}
974+
959975
gulp.task('bundle.js.dev.deps', ['bundle.js.dev'], function() {
960976
return bundler.modify(JS_DEV_DEPS.concat(['dist/build/angular2.dev.js']), 'angular2.dev.js')
977+
.pipe(insert.transform(insertRXLicense))
961978
.pipe(insert.append('\nSystem.config({"paths":{"*":"*.js","angular2/*":"angular2/*"}});\n'))
962979
.pipe(gulp.dest('dist/bundle'));
963980
});
964981

965982
gulp.task('bundle.js.sfx.dev.deps', ['bundle.js.sfx.dev'], function() {
966983
return bundler.modify(JS_DEV_DEPS.concat(['dist/build/angular2.sfx.dev.js']),
967984
'angular2.sfx.dev.js')
985+
.pipe(insert.transform(insertRXLicense))
968986
.pipe(gulp.dest('dist/bundle'));
969987
});
970988

tools/build/licensewrap.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var fs = require('fs');
2+
module.exports = function(licenseFile, outputFile) {
3+
var licenseText = fs.readFileSync(licenseFile);
4+
var license = "/**\n @license\n" + licenseText + "\n */\n";
5+
if (outputFile) {
6+
outputFile = licenseFile + '.wrapped';
7+
fs.writeFileSync(outputFile, license, 'utf8');
8+
return outputFile;
9+
} else {
10+
return license;
11+
}
12+
};

0 commit comments

Comments
 (0)
X Tutup