File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 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 => / ^ R x \. ? .* \. j s $ / . 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 ) ) ;
Original file line number Diff line number Diff 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
2729function 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 #
You can’t perform that action at this time.
0 commit comments