Skip to content

Commit 00822c3

Browse files
committed
chore(publish): add Rx bundles to code.angularjs.org publish step
Closes angular#5904 Closes angular#5909
1 parent 3dca9d5 commit 00822c3

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#! /usr/bin/env node
2+
3+
/**
4+
* TODO: remove this file when license is included in RxJS bundles.
5+
* https://github.com/ReactiveX/RxJS/issues/1067
6+
*
7+
* This script runs after bundles have already been copied to the build-path,
8+
* to prepend the license to each bundle.
9+
**/
10+
var fs = require('fs');
11+
var args = require('minimist')(process.argv);
12+
13+
var license = fs.readFileSync(args['license-path']);
14+
// Make the license block into a JS comment
15+
license = `/**
16+
${license}
17+
**/
18+
`;
19+
20+
var bundles = fs.readdirSync(args['build-path'])
21+
// Match files that begin with Rx and end with js
22+
.filter(bundle => /^Rx\.?.*\.js$/.test(bundle))
23+
// Load file contents
24+
.map(bundle => {
25+
return {
26+
path: bundle,
27+
contents: fs.readFileSync(`${args['build-path']}/${bundle}`).toString()
28+
};
29+
})
30+
// Concatenate license to bundle
31+
.map(bundle => {
32+
return {
33+
path: bundle.path,
34+
contents: `${license}${bundle.contents}`
35+
};
36+
})
37+
// Write file to disk
38+
.forEach(bundle => fs.writeFileSync(`${args['build-path']}/${bundle.path}`, bundle.contents));

tools/code.angularjs.org/publish.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ function init {
2222
else
2323
IS_SNAPSHOT_BUILD=
2424
fi
25+
RX_BUNDLE_DIR=$(resolveDir ../../node_modules/rxjs/bundles)
26+
RX_LICENSE=$(resolveDir ../../node_modules/rxjs)/LICENSE.txt
2527
}
2628

2729
function prepare {
@@ -54,6 +56,8 @@ function prepare {
5456
#
5557
mkdir $REPO_DIR/$NEW_VERSION
5658
cp -r $BUILD_DIR/* $REPO_DIR/$NEW_VERSION/
59+
cp -r $RX_BUNDLE_DIR/* $REPO_DIR/$NEW_VERSION/
60+
node ./add-license-to-rx.js --license-path=$RX_LICENSE --build-path=$REPO_DIR/$NEW_VERSION
5761
fi
5862

5963
#

0 commit comments

Comments
 (0)