feat(license): include license files in dev and dev.sfx bundles
This commit is contained in:
parent
cf103de4a7
commit
1eab4f5f07
20
gulpfile.js
20
gulpfile.js
|
@ -16,6 +16,7 @@ var madge = require('madge');
|
||||||
var merge = require('merge');
|
var merge = require('merge');
|
||||||
var merge2 = require('merge2');
|
var merge2 = require('merge2');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
var licenseWrap = require('./tools/build/licensewrap');
|
||||||
|
|
||||||
var watch = require('./tools/build/watch');
|
var watch = require('./tools/build/watch');
|
||||||
|
|
||||||
|
@ -951,13 +952,29 @@ gulp.task('bundle.js.min.deps', ['bundle.js.min'], function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var JS_DEV_DEPS = [
|
var JS_DEV_DEPS = [
|
||||||
|
licenseWrap('node_modules/zone.js/LICENSE', true),
|
||||||
'node_modules/zone.js/dist/zone-microtask.js',
|
'node_modules/zone.js/dist/zone-microtask.js',
|
||||||
'node_modules/zone.js/dist/long-stack-trace-zone.js',
|
'node_modules/zone.js/dist/long-stack-trace-zone.js',
|
||||||
'node_modules/reflect-metadata/Reflect.js'
|
licenseWrap('node_modules/reflect-metadata/LICENSE', true),
|
||||||
|
'node_modules/reflect-metadata/Reflect.js',
|
||||||
|
// traceur-runtime is always first in the bundle
|
||||||
|
licenseWrap('node_modules/traceur/LICENSE', true)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Splice in RX license if rx is in the bundle.
|
||||||
|
function insertRXLicense(source) {
|
||||||
|
var n = source.indexOf('System.register("rx"');
|
||||||
|
if (n >= 0) {
|
||||||
|
var rxLicense = licenseWrap('node_modules/rx/license.txt');
|
||||||
|
return source.slice(0, n) + rxLicense + source.slice(n);
|
||||||
|
} else {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gulp.task('bundle.js.dev.deps', ['bundle.js.dev'], function() {
|
gulp.task('bundle.js.dev.deps', ['bundle.js.dev'], function() {
|
||||||
return bundler.modify(JS_DEV_DEPS.concat(['dist/build/angular2.dev.js']), 'angular2.dev.js')
|
return bundler.modify(JS_DEV_DEPS.concat(['dist/build/angular2.dev.js']), 'angular2.dev.js')
|
||||||
|
.pipe(insert.transform(insertRXLicense))
|
||||||
.pipe(insert.append('\nSystem.config({"paths":{"*":"*.js","angular2/*":"angular2/*"}});\n'))
|
.pipe(insert.append('\nSystem.config({"paths":{"*":"*.js","angular2/*":"angular2/*"}});\n'))
|
||||||
.pipe(gulp.dest('dist/bundle'));
|
.pipe(gulp.dest('dist/bundle'));
|
||||||
});
|
});
|
||||||
|
@ -965,6 +982,7 @@ gulp.task('bundle.js.dev.deps', ['bundle.js.dev'], function() {
|
||||||
gulp.task('bundle.js.sfx.dev.deps', ['bundle.js.sfx.dev'], function() {
|
gulp.task('bundle.js.sfx.dev.deps', ['bundle.js.sfx.dev'], function() {
|
||||||
return bundler.modify(JS_DEV_DEPS.concat(['dist/build/angular2.sfx.dev.js']),
|
return bundler.modify(JS_DEV_DEPS.concat(['dist/build/angular2.sfx.dev.js']),
|
||||||
'angular2.sfx.dev.js')
|
'angular2.sfx.dev.js')
|
||||||
|
.pipe(insert.transform(insertRXLicense))
|
||||||
.pipe(gulp.dest('dist/bundle'));
|
.pipe(gulp.dest('dist/bundle'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
var fs = require('fs');
|
||||||
|
module.exports = function(licenseFile, outputFile) {
|
||||||
|
var licenseText = fs.readFileSync(licenseFile);
|
||||||
|
var license = "/**\n @license\n" + licenseText + "\n */\n";
|
||||||
|
if (outputFile) {
|
||||||
|
outputFile = licenseFile + '.wrapped';
|
||||||
|
fs.writeFileSync(outputFile, license, 'utf8');
|
||||||
|
return outputFile;
|
||||||
|
} else {
|
||||||
|
return license;
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue