From 769737b9695642232ed6eb82cfc87e55b6aaac0a Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 13 Sep 2017 17:14:40 -0700 Subject: [PATCH 1/2] Create a short command to run working tests from a clean repo --- gulpfile.js | 39 ++++++++++++++++++++++---- package.json | 29 +++++++++++-------- packages/grpc-health-check/gulpfile.js | 16 +++++++---- packages/grpc-js-core/gulpfile.js | 13 ++++++--- packages/grpc-js-core/package.json | 11 +------- packages/grpc-native-core/gulpfile.js | 14 +++++++-- packages/grpc-native-core/package.json | 2 -- test/api/surface_test.js | 30 +++++--------------- test/gulpfile.js | 6 ++-- 9 files changed, 93 insertions(+), 67 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 2c0011d9..a564173b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,6 @@ 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); @@ -9,19 +10,47 @@ require('./packages/grpc-js-core/gulpfile'); require('./packages/grpc-native-core/gulpfile'); require('./test/gulpfile'); +const root = __dirname; + +gulp.task('install.all', 'Install dependencies for all subdirectory packages', + ['js.core.install', 'native.core.install', 'health-check.install']); + gulp.task('lint', 'Emit linting errors in source and test files', ['js.core.lint', 'native.core.lint']); -gulp.task('link', 'Link local packages together', - ['health-check.link', 'internal.test.link']); +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', 'link']); +gulp.task('build', 'Build packages', ['install.all'], () => { + gulp.start('build.only'); +}); + +gulp.task('link.create.only', 'Initialize npm links to packages without rebuilding', + ['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'], () => { + gulp.start('link.only'); + }); 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.start('native.test.only'); +}); + gulp.task('test.only', 'Run tests without rebuilding anything', - ['js.core.test', 'native.core.test', 'internal.test.test', 'health-check.test']); + ['js.core.test', 'native.test.only']); gulp.task('test', 'Run all tests', ['build', 'link'], () => { gulp.start('test.only'); diff --git a/package.json b/package.json index 82aa3a18..88da4466 100644 --- a/package.json +++ b/package.json @@ -8,27 +8,34 @@ "name": "Google Inc." }, "license": "Apache-2.0", - "devDependencies": { + "dependencies": { "async": "^2.5.0", "body-parser": "^1.18.0", "express": "^4.15.4", "google-auth-library": "^0.11.0", - "grpc": "^1.6.0", - "gulp": "^3.9.1", - "gulp-help": "^1.6.1", "lodash": "^4.17.4", "poisson-process": "^0.2.2" }, - "scripts": { - "install": "cd packages/grpc-js-core && npm install" + "devDependencies": { + "del": "^3.0.0", + "gulp": "^3.9.1", + "gulp-help": "^1.6.1", + "gulp-jshint": "^2.0.4", + "gulp-mocha": "^4.3.1", + "gulp-sourcemaps": "^2.6.1", + "gulp-tslint": "^8.1.1", + "gulp-typescript": "^3.2.2", + "gulp-util": "^3.0.8", + "jshint": "^2.9.5", + "merge2": "^1.1.0", + "mocha": "^3.5.3", + "through2": "^2.0.3", + "tslint": "^5.5.0", + "typescript": "^2.5.1" }, "contributors": [ { "name": "Google Inc." } - ], - "dependencies": { - "gulp-mocha": "^4.3.1", - "mocha": "^3.5.3" - } + ] } diff --git a/packages/grpc-health-check/gulpfile.js b/packages/grpc-health-check/gulpfile.js index 79e0e437..996fd52f 100644 --- a/packages/grpc-health-check/gulpfile.js +++ b/packages/grpc-health-check/gulpfile.js @@ -6,15 +6,19 @@ const path = require('path'); const gulp = help(_gulp); -const hcCoreDir = __dirname; -const baseDir = path.resolve(hcCoreDir, '..', '..'); -const testDir = path.resolve(hcCoreDir, 'test'); +const healthCheckDir = __dirname; +const baseDir = path.resolve(healthCheckDir, '..', '..'); +const testDir = path.resolve(healthCheckDir, 'test'); -gulp.task('health-check.link', 'Link local copy of grpc', (cb) => { - return exec(`cd ${hcCoreDir} && npm link ${baseDir}/packages/grpc-native-core`, cb); +gulp.task('health-check.install', 'Install health check dependencies', (cb) => { + return exec(`cd ${healthCheckDir} && npm install`, cb); }); -gulp.task('health-check.test', 'Run health check tests', ['health-check.link'], +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.test', 'Run health check tests', ['health-check.install', 'health-check.link.add'], () => { return gulp.src(`${testDir}/*.js`).pipe(mocha()); }); diff --git a/packages/grpc-js-core/gulpfile.js b/packages/grpc-js-core/gulpfile.js index 5416b30f..5a948b02 100644 --- a/packages/grpc-js-core/gulpfile.js +++ b/packages/grpc-js-core/gulpfile.js @@ -13,6 +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; Error.stackTraceLimit = Infinity; @@ -75,10 +76,14 @@ function makeCompileFn(globs) { }; } +gulp.task('js.core.install', 'Install native core dependencies', (cb) => { + return exec(`cd ${jsCoreDir} && npm install`, cb); +}); + /** * 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/.', () => { +gulp.task('js.core.lint', 'Emits linting errors found in src/ and test/.', ['js.core.install'], () => { const program = require('tslint').Linter.createProgram(tsconfigPath); gulp.src([`${srcDir}/**/*.ts`, `${testDir}/**/*.ts`]) .pipe(tslint({ @@ -100,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/.', +gulp.task('js.core.compile', 'Transpiles src/.', ['js.core.install'], 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.compile'], +gulp.task('js.core.test.compile', 'After dep tasks, transpiles test/.', ['js.core.install', 'js.core.compile'], makeCompileFn({ transpile: [`${testDir}/**/*.ts`], copy: `${testDir}/**/!(*.ts)` })); /** @@ -122,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.', +gulp.task('js.core.compile.single', 'Transpiles individual files specified by --file.', ['js.core.install'], makeCompileFn({ transpile: files.map(f => path.relative('.', f)) }) diff --git a/packages/grpc-js-core/package.json b/packages/grpc-js-core/package.json index ac271387..a5d3e044 100644 --- a/packages/grpc-js-core/package.json +++ b/packages/grpc-js-core/package.json @@ -18,16 +18,7 @@ "@types/mocha": "^2.2.42", "@types/node": "^8.0.25", "clang-format": "^1.0.53", - "del": "^3.0.0", - "google-ts-style": "^0.2.0", - "gulp-sourcemaps": "^2.6.1", - "gulp-tslint": "^8.1.1", - "gulp-typescript": "^3.2.2", - "gulp-util": "^3.0.8", - "merge2": "^1.1.0", - "through2": "^2.0.3", - "tslint": "^5.5.0", - "typescript": "^2.5.1" + "google-ts-style": "^0.2.0" }, "contributors": [ { diff --git a/packages/grpc-native-core/gulpfile.js b/packages/grpc-native-core/gulpfile.js index def55c31..9da37213 100644 --- a/packages/grpc-native-core/gulpfile.js +++ b/packages/grpc-native-core/gulpfile.js @@ -16,16 +16,24 @@ const testDir = path.resolve(nativeCoreDir, 'test'); const pkg = require('./package'); const jshintConfig = pkg.jshintConfig; -gulp.task('native.core.lint', 'Emits linting errors', () => { +gulp.task('native.core.install', 'Install native core dependencies', (cb) => { + return exec(`cd ${nativeCoreDir} && npm install`, cb); +}); + +gulp.task('native.core.link.create', 'Create npm link', ['native.core.install'], (cb) => { + return exec(`cd ${nativeCoreDir} && npm link`, cb); +}); + +gulp.task('native.core.lint', 'Emits linting errors', ['native.core.install'], () => { 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', (cb) => { +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.test', 'Run all tests', ['native.core.build'], () => { +gulp.task('native.core.test', 'Run all tests', ['native.core.install', 'native.core.build'], () => { return gulp.src(`${testDir}/*.js`).pipe(mocha()); }); diff --git a/packages/grpc-native-core/package.json b/packages/grpc-native-core/package.json index 47c37ba3..26d43447 100644 --- a/packages/grpc-native-core/package.json +++ b/packages/grpc-native-core/package.json @@ -31,7 +31,6 @@ ], "dependencies": { "arguejs": "^0.2.3", - "gulp-jshint": "^2.0.4", "lodash": "^4.15.0", "nan": "^2.0.0", "node-pre-gyp": "^0.6.35", @@ -46,7 +45,6 @@ "google-protobuf": "^3.0.0", "istanbul": "^0.4.4", "jsdoc": "^3.3.2", - "jshint": "^2.5.0", "minimist": "^1.1.0", "mocha-jenkins-reporter": "^0.2.3", "poisson-process": "^0.2.1" diff --git a/test/api/surface_test.js b/test/api/surface_test.js index 0203931b..72a20fb9 100644 --- a/test/api/surface_test.js +++ b/test/api/surface_test.js @@ -21,8 +21,6 @@ var assert = require('assert'); var _ = require('lodash'); -var ProtoBuf = require('protobufjs'); - var grpc = require('grpc'); var MathClient = grpc.load( @@ -283,9 +281,7 @@ describe('Echo service', function() { var server; var client; before(function() { - var test_proto = ProtoBuf.loadProtoFile(__dirname + '/echo_service.proto'); - var echo_service = test_proto.lookup('EchoService'); - var Client = grpc.loadObject(echo_service); + var Client = grpc.load(__dirname + '/echo_service.proto').EchoService; server = new grpc.Server(); server.addService(Client.service, { echo: function(call, callback) { @@ -413,9 +409,7 @@ describe('Echo metadata', function() { var server; var metadata; before(function() { - var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto'); - var test_service = test_proto.lookup('TestService'); - var Client = grpc.loadObject(test_service); + var Client = grpc.load(__dirname + '/test_service.proto').TestService; server = new grpc.Server(); server.addService(Client.service, { unary: function(call, cb) { @@ -514,8 +508,7 @@ describe('Client malformed response handling', function() { var client; var badArg = new Buffer([0xFF]); before(function() { - var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto'); - var test_service = test_proto.lookup('TestService'); + var Client = grpc.load(__dirname + '/test_service.proto').TestService; var malformed_test_service = { unary: { path: '/TestService/Unary', @@ -572,7 +565,6 @@ describe('Client malformed response handling', function() { } }); var port = server.bind('localhost:0', server_insecure_creds); - var Client = grpc.loadObject(test_service); client = new Client('localhost:' + port, grpc.credentials.createInsecure()); server.start(); }); @@ -621,8 +613,7 @@ describe('Server serialization failure handling', function() { var client; var server; before(function() { - var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto'); - var test_service = test_proto.lookup('TestService'); + var Client = grpc.load(__dirname + '/test_service.proto').TestService; var malformed_test_service = { unary: { path: '/TestService/Unary', @@ -679,7 +670,6 @@ describe('Server serialization failure handling', function() { } }); var port = server.bind('localhost:0', server_insecure_creds); - var Client = grpc.loadObject(test_service); client = new Client('localhost:' + port, grpc.credentials.createInsecure()); server.start(); }); @@ -727,9 +717,7 @@ describe('Other conditions', function() { var server; var port; before(function() { - var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto'); - var test_service = test_proto.lookup('TestService'); - Client = grpc.loadObject(test_service); + Client = grpc.load(__dirname + '/test_service.proto').TestService; server = new grpc.Server(); var trailer_metadata = new grpc.Metadata(); trailer_metadata.add('trailer-present', 'yes'); @@ -1084,10 +1072,8 @@ describe('Call propagation', function() { var client; var server; before(function() { - var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto'); - var test_service = test_proto.lookup('TestService'); + Client = grpc.load(__dirname + '/test_service.proto').TestService; server = new grpc.Server(); - Client = grpc.loadObject(test_service); server.addService(Client.service, { unary: function(call) {}, clientStream: function(stream) {}, @@ -1336,9 +1322,7 @@ describe('Client reconnect', function() { var client; var port; beforeEach(function() { - var test_proto = ProtoBuf.loadProtoFile(__dirname + '/echo_service.proto'); - var echo_service = test_proto.lookup('EchoService'); - Client = grpc.loadObject(echo_service); + Client = grpc.load(__dirname + '/echo_service.proto').EchoService; server = new grpc.Server(); server.addService(Client.service, { echo: function(call, callback) { diff --git a/test/gulpfile.js b/test/gulpfile.js index ffe53c6d..7956a0b5 100644 --- a/test/gulpfile.js +++ b/test/gulpfile.js @@ -10,10 +10,10 @@ const gulp = help(_gulp); const testDir = __dirname; const apiTestDir = path.resolve(testDir, 'api'); -gulp.task('internal.test.link', 'Link local copies of grpc packages', (cb) => { - return exec(`npm link ${testDir}/../packages/grpc-native-core`, cb); +gulp.task('internal.test.link.add', 'Link local copies of grpc packages', (cb) => { + return exec(`npm link grpc`, cb); }); -gulp.task('internal.test.test', 'Run API-level tests', ['internal.test.link'], () => { +gulp.task('internal.test.test', 'Run API-level tests', ['internal.test.link.add'], () => { return gulp.src(`${apiTestDir}/*.js`).pipe(mocha()); }); From 3d4dddd8ccee315fe7fb3227bd5c1f4e0b25d91f Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 14 Sep 2017 10:59:20 -0700 Subject: [PATCH 2/2] Switch to execa. Separate setup and rebuild/test tasks --- gulpfile.js | 22 +++++++--------------- package.json | 1 + packages/grpc-health-check/gulpfile.js | 12 ++++++------ packages/grpc-js-core/gulpfile.js | 14 +++++++------- packages/grpc-native-core/gulpfile.js | 19 ++++++++++--------- test/gulpfile.js | 8 ++++---- 6 files changed, 35 insertions(+), 41 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index a564173b..7bcf804e 100644 --- a/gulpfile.js +++ b/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'); }); diff --git a/package.json b/package.json index 88da4466..1211e297 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/grpc-health-check/gulpfile.js b/packages/grpc-health-check/gulpfile.js index 996fd52f..e66ec72a 100644 --- a/packages/grpc-health-check/gulpfile.js +++ b/packages/grpc-health-check/gulpfile.js @@ -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()); }); diff --git a/packages/grpc-js-core/gulpfile.js b/packages/grpc-js-core/gulpfile.js index 5a948b02..cdf046ee 100644 --- a/packages/grpc-js-core/gulpfile.js +++ b/packages/grpc-js-core/gulpfile.js @@ -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)) }) diff --git a/packages/grpc-native-core/gulpfile.js b/packages/grpc-native-core/gulpfile.js index 9da37213..00b1ffd8 100644 --- a/packages/grpc-native-core/gulpfile.js +++ b/packages/grpc-native-core/gulpfile.js @@ -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()); }); diff --git a/test/gulpfile.js b/test/gulpfile.js index 7956a0b5..b3b49b1f 100644 --- a/test/gulpfile.js +++ b/test/gulpfile.js @@ -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()); });