From 00822c34155b4f56d555f99545f7b32ff5d4bed5 Mon Sep 17 00:00:00 2001 From: Jeff Cross Date: Tue, 15 Dec 2015 07:36:56 -0800 Subject: [PATCH] chore(publish): add Rx bundles to code.angularjs.org publish step Closes #5904 Closes #5909 --- tools/code.angularjs.org/add-license-to-rx.js | 38 +++++++++++++++++++ tools/code.angularjs.org/publish.sh | 4 ++ 2 files changed, 42 insertions(+) create mode 100644 tools/code.angularjs.org/add-license-to-rx.js diff --git a/tools/code.angularjs.org/add-license-to-rx.js b/tools/code.angularjs.org/add-license-to-rx.js new file mode 100644 index 0000000000..559671385d --- /dev/null +++ b/tools/code.angularjs.org/add-license-to-rx.js @@ -0,0 +1,38 @@ +#! /usr/bin/env node + +/** + * TODO: remove this file when license is included in RxJS bundles. + * https://github.com/ReactiveX/RxJS/issues/1067 + * + * This script runs after bundles have already been copied to the build-path, + * to prepend the license to each bundle. + **/ +var fs = require('fs'); +var args = require('minimist')(process.argv); + +var license = fs.readFileSync(args['license-path']); +// Make the license block into a JS comment +license = `/** +${license} +**/ +`; + +var bundles = fs.readdirSync(args['build-path']) + // Match files that begin with Rx and end with js + .filter(bundle => /^Rx\.?.*\.js$/.test(bundle)) + // Load file contents + .map(bundle => { + return { + path: bundle, + contents: fs.readFileSync(`${args['build-path']}/${bundle}`).toString() + }; + }) + // Concatenate license to bundle + .map(bundle => { + return { + path: bundle.path, + contents: `${license}${bundle.contents}` + }; + }) + // Write file to disk + .forEach(bundle => fs.writeFileSync(`${args['build-path']}/${bundle.path}`, bundle.contents)); diff --git a/tools/code.angularjs.org/publish.sh b/tools/code.angularjs.org/publish.sh index c334221b3d..5fe04e4e70 100755 --- a/tools/code.angularjs.org/publish.sh +++ b/tools/code.angularjs.org/publish.sh @@ -22,6 +22,8 @@ function init { else IS_SNAPSHOT_BUILD= fi + RX_BUNDLE_DIR=$(resolveDir ../../node_modules/rxjs/bundles) + RX_LICENSE=$(resolveDir ../../node_modules/rxjs)/LICENSE.txt } function prepare { @@ -54,6 +56,8 @@ function prepare { # mkdir $REPO_DIR/$NEW_VERSION cp -r $BUILD_DIR/* $REPO_DIR/$NEW_VERSION/ + cp -r $RX_BUNDLE_DIR/* $REPO_DIR/$NEW_VERSION/ + node ./add-license-to-rx.js --license-path=$RX_LICENSE --build-path=$REPO_DIR/$NEW_VERSION fi #