Added gulp task to auto-point to node-h2 binary

This commit is contained in:
Kelvin Jin 2017-08-03 14:42:00 -07:00
parent 3995a13d22
commit 115edf56dc
3 changed files with 44 additions and 4 deletions

View File

@ -1,3 +1,4 @@
const { execFile } = require('child_process');
const gulp = require('gulp');
const merge2 = require('merge2');
const path = require('path');
@ -34,6 +35,24 @@ function makeCompileFn(dev) {
};
}
/**
* If process.env.NODE_H2 is defined and nvm is installed, uses nvm to set
* $NODE_H2 as the default node binary (with --expose-http2 included).
*/
gulp.task('h2-setup', () => {
return new Promise((resolve, reject) => {
execFile('./setup.sh', (err, stdout, stderr) => {
(stdout = stdout.trim()) && console.log(stdout);
(stderr = stderr.trim()) && console.error(stderr);
if (err) {
reject(err);
} else {
resolve();
}
});
});
})
/**
* Runs tslint on files in src/, with linting rules defined in tslint.json.
*/

View File

@ -14,16 +14,16 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@types/node": "^8.0.17",
"@types/node": "^8.0.19",
"clang-format": "^1.0.53",
"google-ts-style": "latest",
"gulp": "^3.9.1",
"gulp-sourcemaps": "^2.6.0",
"gulp-tslint": "^8.1.1",
"gulp-typescript": "^3.2.1",
"merge2": "^1.1.0",
"typescript": "^2.4.1",
"google-ts-style": "latest",
"tslint": "^5.5.0"
"tslint": "^5.5.0",
"typescript": "^2.4.1"
},
"contributors": [
{

21
setup.sh Executable file
View File

@ -0,0 +1,21 @@
if [ -z $NODE_H2 ]; then
echo "\$NODE_H2 must point to a node binary"
exit 1
fi
if [ -z $NVM_DIR ]; then
echo "nvm must be installed"
exit 1
fi
NVM_H2_DIR=$NVM_DIR/versions/node/v9.0.0-pre
cp -r $NVM_DIR/versions/node/v8.2.1 $NVM_H2_DIR
rm -r $NVM_H2_DIR/bin
mkdir $NVM_H2_DIR/bin
echo $NODE_H2 '--expose-http2 "$@"' > $NVM_H2_DIR/bin/node
ln -s $NVM_H2_DIR/lib/node_modules/npm/bin/npm-cli.js $NVM_H2_DIR/bin/npm
ln -s $NVM_H2_DIR/lib/node_modules/npm/bin/npx-cli.js $NVM_H2_DIR/bin/npx
chmod +x $NVM_H2_DIR/bin/node
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm use v9.0.0-pre 2>/dev/null
nvm use --delete-prefix v9.0.0-pre