Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Node.js-like runtimes to identify as Node.js as well. #2357

Merged
merged 1 commit into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/apollo-server-core/src/utils/createSHA.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import isNode from './isNode';
import isNodeLike from './isNodeLike';

export default function(kind: string): import('crypto').Hash {
if (isNode) {
if (isNodeLike) {
// Use module.require instead of just require to avoid bundling whatever
// crypto polyfills a non-Node bundler might fall back to.
return module.require('crypto').createHash(kind);
Expand Down
6 changes: 0 additions & 6 deletions packages/apollo-server-core/src/utils/isNode.ts

This file was deleted.

11 changes: 11 additions & 0 deletions packages/apollo-server-core/src/utils/isNodeLike.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default typeof process === 'object' &&
process &&
// We used to check `process.release.name === "node"`, however that doesn't
// account for certain forks of Node.js which are otherwise identical to
// Node.js. For example, NodeSource's N|Solid reports itself as "nsolid",
// though it's mostly the same build of Node.js with an extra addon.
process.release &&
process.versions &&
// The one thing which is present on both Node.js and N|Solid (a fork of
// Node.js), is `process.versions.node` being defined.
typeof process.versions.node === 'string';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import isNode from './isNode';
import isNodeLike from './isNodeLike';

const runtimeSupportsUploads = (() => {
if (isNode) {
if (isNodeLike) {
const [nodeMajor, nodeMinor] = process.versions.node
.split('.', 2)
.map(segment => parseInt(segment, 10));
Expand Down