Skip to content

Commit

Permalink
feat!: throw for versions of Node.js older than v10.0.0 (#748)
Browse files Browse the repository at this point in the history
* feat!: throw for versions of Node.js older than v10.0.0

* chore: address code review

* chore: add a space

* chore: remove node 8 from CI

Co-authored-by: Alexander Fenster <[email protected]>
  • Loading branch information
bcoe and alexander-fenster authored Mar 20, 2020
1 parent b1eccf9 commit 511fc23
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [8, 10, 12, 13]
node: [10, 12, 13]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
Expand Down
19 changes: 10 additions & 9 deletions src/grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,20 @@ export class GrpcClient {
this.auth = options.auth || new GoogleAuth(options);
this.fallback = false;

const minimumVersion = '10.0.0';
if (semver.lt(process.version, minimumVersion)) {
const errorMessage =
`Node.js v${minimumVersion} is a minimum requirement. To learn about legacy version support visit: ` +
'https://github.com/googleapis/google-cloud-node#supported-nodejs-versions';
throw new Error(errorMessage);
}

if ('grpc' in options) {
this.grpc = options.grpc!;
this.grpcVersion = '';
} else {
if (semver.gte(process.version, '8.13.0')) {
this.grpc = grpc;
this.grpcVersion = require('@grpc/grpc-js/package.json').version;
} else {
const errorMessage =
'To use @grpc/grpc-js you must run your code on Node.js v8.13.0 or newer. Please see README if you need to use an older version. ' +
'https://github.com/googleapis/gax-nodejs/blob/master/README.md';
throw new Error(errorMessage);
}
this.grpc = grpc;
this.grpcVersion = require('@grpc/grpc-js/package.json').version;
}
}

Expand Down

0 comments on commit 511fc23

Please sign in to comment.