mirror of https://github.com/grpc/grpc-node.git
Switch to execa. Separate setup and rebuild/test tasks
This commit is contained in:
parent
769737b969
commit
3d4dddd8cc
22
gulpfile.js
22
gulpfile.js
|
@ -1,6 +1,5 @@
|
|||
const _gulp = require('gulp');
|
||||
const help = require('gulp-help');
|
||||
const exec = require('child_process').exec;
|
||||
|
||||
// gulp-help monkeypatches tasks to have an additional description parameter
|
||||
const gulp = help(_gulp);
|
||||
|
@ -18,41 +17,34 @@ gulp.task('install.all', 'Install dependencies for all subdirectory packages',
|
|||
gulp.task('lint', 'Emit linting errors in source and test files',
|
||||
['js.core.lint', 'native.core.lint']);
|
||||
|
||||
gulp.task('build.only', 'Build packages without doing any installation',
|
||||
['js.core.compile', 'native.core.build']);
|
||||
gulp.task('build', 'Build packages', ['js.core.compile', 'native.core.build']);
|
||||
|
||||
gulp.task('build', 'Build packages', ['install.all'], () => {
|
||||
gulp.start('build.only');
|
||||
});
|
||||
|
||||
gulp.task('link.create.only', 'Initialize npm links to packages without rebuilding',
|
||||
gulp.task('link.create', 'Initialize npm links to packages',
|
||||
['native.core.link.create']);
|
||||
|
||||
gulp.task('link.create', 'Initialize npm links to packages', ['build'], () => {
|
||||
gulp.start('link.create.only');
|
||||
});
|
||||
|
||||
gulp.task('link.only', 'Link packages together without rebuilding anything',
|
||||
['health-check.link.add', 'internal.test.link.add']);
|
||||
|
||||
gulp.task('link', 'Link local packages together after building',
|
||||
['build', 'link.create.only'], () => {
|
||||
['link.create'], () => {
|
||||
gulp.start('link.only');
|
||||
});
|
||||
|
||||
gulp.task('setup', 'One-time setup for a clean repository', ['install.all', 'link']);
|
||||
|
||||
gulp.task('clean', 'Delete generated files', ['js.core.clean']);
|
||||
|
||||
gulp.task('native.test.only', 'Run tests of native code without rebuilding anything',
|
||||
['native.core.test', 'internal.test.test', 'health-check.test']);
|
||||
|
||||
gulp.task('native.test', 'Run tests of native code', ['build', 'link'], () => {
|
||||
gulp.task('native.test', 'Run tests of native code', ['build'], () => {
|
||||
gulp.start('native.test.only');
|
||||
});
|
||||
|
||||
gulp.task('test.only', 'Run tests without rebuilding anything',
|
||||
['js.core.test', 'native.test.only']);
|
||||
|
||||
gulp.task('test', 'Run all tests', ['build', 'link'], () => {
|
||||
gulp.task('test', 'Run all tests', ['build'], () => {
|
||||
gulp.start('test.only');
|
||||
});
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
"dependencies": {
|
||||
"async": "^2.5.0",
|
||||
"body-parser": "^1.18.0",
|
||||
"execa": "^0.8.0",
|
||||
"express": "^4.15.4",
|
||||
"google-auth-library": "^0.11.0",
|
||||
"lodash": "^4.17.4",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const _gulp = require('gulp');
|
||||
const help = require('gulp-help');
|
||||
const mocha = require('gulp-mocha');
|
||||
const exec = require('child_process').exec;
|
||||
const execa = require('execa');
|
||||
const path = require('path');
|
||||
|
||||
const gulp = help(_gulp);
|
||||
|
@ -10,15 +10,15 @@ const healthCheckDir = __dirname;
|
|||
const baseDir = path.resolve(healthCheckDir, '..', '..');
|
||||
const testDir = path.resolve(healthCheckDir, 'test');
|
||||
|
||||
gulp.task('health-check.install', 'Install health check dependencies', (cb) => {
|
||||
return exec(`cd ${healthCheckDir} && npm install`, cb);
|
||||
gulp.task('health-check.install', 'Install health check dependencies', () => {
|
||||
return execa('npm', ['install'], {cwd: healthCheckDir, stdio: 'inherit'});
|
||||
});
|
||||
|
||||
gulp.task('health-check.link.add', 'Link local copy of grpc', ['health-check.install'], (cb) => {
|
||||
return exec(`cd ${healthCheckDir} && npm link grpc`, cb);
|
||||
gulp.task('health-check.link.add', 'Link local copy of grpc', ['health-check.install'], () => {
|
||||
return execa('npm', ['link', 'grpc'], {cwd: healthCheckDir, stdio: 'inherit'});
|
||||
});
|
||||
|
||||
gulp.task('health-check.test', 'Run health check tests', ['health-check.install', 'health-check.link.add'],
|
||||
gulp.task('health-check.test', 'Run health check tests',
|
||||
() => {
|
||||
return gulp.src(`${testDir}/*.js`).pipe(mocha());
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ const util = require('gulp-util');
|
|||
const merge2 = require('merge2');
|
||||
const path = require('path');
|
||||
const through = require('through2');
|
||||
const exec = require('child_process').exec;
|
||||
const execa = require('execa');
|
||||
|
||||
Error.stackTraceLimit = Infinity;
|
||||
|
||||
|
@ -76,14 +76,14 @@ function makeCompileFn(globs) {
|
|||
};
|
||||
}
|
||||
|
||||
gulp.task('js.core.install', 'Install native core dependencies', (cb) => {
|
||||
return exec(`cd ${jsCoreDir} && npm install`, cb);
|
||||
gulp.task('js.core.install', 'Install native core dependencies', () => {
|
||||
return execa('npm', ['install'], {cwd: jsCoreDir, stdio: 'inherit'});
|
||||
});
|
||||
|
||||
/**
|
||||
* Runs tslint on files in src/, with linting rules defined in tslint.json.
|
||||
*/
|
||||
gulp.task('js.core.lint', 'Emits linting errors found in src/ and test/.', ['js.core.install'], () => {
|
||||
gulp.task('js.core.lint', 'Emits linting errors found in src/ and test/.', () => {
|
||||
const program = require('tslint').Linter.createProgram(tsconfigPath);
|
||||
gulp.src([`${srcDir}/**/*.ts`, `${testDir}/**/*.ts`])
|
||||
.pipe(tslint({
|
||||
|
@ -105,13 +105,13 @@ gulp.task('js.core.clean', 'Deletes transpiled code.', () => {
|
|||
* Currently, all errors are emitted twice. This is being tracked here:
|
||||
* https://github.com/ivogabe/gulp-typescript/issues/438
|
||||
*/
|
||||
gulp.task('js.core.compile', 'Transpiles src/.', ['js.core.install'],
|
||||
gulp.task('js.core.compile', 'Transpiles src/.',
|
||||
makeCompileFn({ transpile: [`${srcDir}/**/*.ts`] }));
|
||||
|
||||
/**
|
||||
* Transpiles TypeScript files in both src/ and test/.
|
||||
*/
|
||||
gulp.task('js.core.test.compile', 'After dep tasks, transpiles test/.', ['js.core.install', 'js.core.compile'],
|
||||
gulp.task('js.core.test.compile', 'After dep tasks, transpiles test/.', ['js.core.compile'],
|
||||
makeCompileFn({ transpile: [`${testDir}/**/*.ts`], copy: `${testDir}/**/!(*.ts)` }));
|
||||
|
||||
/**
|
||||
|
@ -127,7 +127,7 @@ gulp.task('js.core.test', 'After dep tasks, runs all tests.',
|
|||
/**
|
||||
* Transpiles individual files, specified by the --file flag.
|
||||
*/
|
||||
gulp.task('js.core.compile.single', 'Transpiles individual files specified by --file.', ['js.core.install'],
|
||||
gulp.task('js.core.compile.single', 'Transpiles individual files specified by --file.',
|
||||
makeCompileFn({
|
||||
transpile: files.map(f => path.relative('.', f))
|
||||
})
|
||||
|
|
|
@ -6,7 +6,7 @@ const gulp = help(_gulp);
|
|||
|
||||
const jshint = require('gulp-jshint');
|
||||
const mocha = require('gulp-mocha');
|
||||
const exec = require('child_process').exec;
|
||||
const execa = require('execa');
|
||||
const path = require('path');
|
||||
|
||||
const nativeCoreDir = __dirname;
|
||||
|
@ -16,24 +16,25 @@ const testDir = path.resolve(nativeCoreDir, 'test');
|
|||
const pkg = require('./package');
|
||||
const jshintConfig = pkg.jshintConfig;
|
||||
|
||||
gulp.task('native.core.install', 'Install native core dependencies', (cb) => {
|
||||
return exec(`cd ${nativeCoreDir} && npm install`, cb);
|
||||
gulp.task('native.core.install', 'Install native core dependencies', () => {
|
||||
return execa('npm', ['install', '--build-from-source'],
|
||||
{cwd: nativeCoreDir, stdio: 'inherit'});
|
||||
});
|
||||
|
||||
gulp.task('native.core.link.create', 'Create npm link', ['native.core.install'], (cb) => {
|
||||
return exec(`cd ${nativeCoreDir} && npm link`, cb);
|
||||
gulp.task('native.core.link.create', 'Create npm link', ['native.core.install'], () => {
|
||||
return execa('npm', ['link'], {cwd: nativeCoreDir, stdio: 'inherit'});
|
||||
});
|
||||
|
||||
gulp.task('native.core.lint', 'Emits linting errors', ['native.core.install'], () => {
|
||||
gulp.task('native.core.lint', 'Emits linting errors', () => {
|
||||
return gulp.src([`${nativeCoreDir}/index.js`, `${srcDir}/*.js`, `${testDir}/*.js`])
|
||||
.pipe(jshint(pkg.jshintConfig))
|
||||
.pipe(jshint.reporter('default'));
|
||||
});
|
||||
|
||||
gulp.task('native.core.build', 'Build native package', ['native.core.install'], (cb) => {
|
||||
return exec(`cd ${nativeCoreDir} && ${nativeCoreDir}/node_modules/.bin/node-pre-gyp build`, cb);
|
||||
gulp.task('native.core.build', 'Build native package', () => {
|
||||
return execa('node-pre-gyp', ['build'], {cwd: nativeCoreDir, stdio: 'inherit'});
|
||||
});
|
||||
|
||||
gulp.task('native.core.test', 'Run all tests', ['native.core.install', 'native.core.build'], () => {
|
||||
gulp.task('native.core.test', 'Run all tests', ['native.core.build'], () => {
|
||||
return gulp.src(`${testDir}/*.js`).pipe(mocha());
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const _gulp = require('gulp');
|
||||
const help = require('gulp-help');
|
||||
const mocha = require('gulp-mocha');
|
||||
const exec = require('child_process').exec;
|
||||
const execa = require('execa');
|
||||
const path = require('path');
|
||||
|
||||
// gulp-help monkeypatches tasks to have an additional description parameter
|
||||
|
@ -10,10 +10,10 @@ const gulp = help(_gulp);
|
|||
const testDir = __dirname;
|
||||
const apiTestDir = path.resolve(testDir, 'api');
|
||||
|
||||
gulp.task('internal.test.link.add', 'Link local copies of grpc packages', (cb) => {
|
||||
return exec(`npm link grpc`, cb);
|
||||
gulp.task('internal.test.link.add', 'Link local copies of grpc packages', () => {
|
||||
return execa('npm', ['link', 'grpc'], {cwd: testDir, stdio: 'inherit'});
|
||||
});
|
||||
|
||||
gulp.task('internal.test.test', 'Run API-level tests', ['internal.test.link.add'], () => {
|
||||
gulp.task('internal.test.test', 'Run API-level tests', () => {
|
||||
return gulp.src(`${apiTestDir}/*.js`).pipe(mocha());
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue