forked from ReactiveX/rxjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.make-packages.js
36 lines (30 loc) · 1.43 KB
/
.make-packages.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
var pkg = require('./package.json');
var fs = require('fs');
var mkdirp = require('mkdirp');
var path = require('path');
var licenseTool = require('./tools/add-license-to-file');
var addLicenseToFile = licenseTool.addLicenseToFile;
var addLicenseTextToFile = licenseTool.addLicenseTextToFile;
// License info for minified files
var licenseUrl = 'https://github.com/ReactiveX/RxJS/blob/master/LICENSE.txt';
var license = 'Apache License 2.0 ' + licenseUrl;
delete pkg.scripts;
var cjsPkg = Object.assign({}, pkg, {
name: 'rxjs',
main: 'Rx.js',
typings: 'Rx.d.ts'
});
fs.writeFileSync('dist/cjs/package.json', JSON.stringify(cjsPkg, null, 2));
fs.writeFileSync('dist/cjs/LICENSE.txt', fs.readFileSync('./LICENSE.txt').toString());
fs.writeFileSync('dist/cjs/README.md', fs.readFileSync('./README.md').toString());
// Bundles for CJS only
mkdirp.sync('dist/cjs/bundles');
// UMD bundles
fs.writeFileSync('dist/cjs/bundles/Rx.js', fs.readFileSync('dist/global/Rx.js').toString());
fs.writeFileSync('dist/cjs/bundles/Rx.min.js', fs.readFileSync('dist/global/Rx.min.js').toString());
fs.writeFileSync('dist/cjs/bundles/Rx.min.js.map', fs.readFileSync('dist/global/Rx.min.js.map').toString());
// Add licenses to tops of bundles
addLicenseToFile('LICENSE.txt', 'dist/cjs/bundles/Rx.js');
addLicenseTextToFile(license, 'dist/cjs/bundles/Rx.min.js');
addLicenseToFile('LICENSE.txt', 'dist/global/Rx.js');
addLicenseTextToFile(license, 'dist/global/Rx.min.js');