Skip to content

Commit

Permalink
Support forks of Node that override process.release.name.
Browse files Browse the repository at this point in the history
For more context, see: apollographql/apollo-server#2357
  • Loading branch information
trevor-scheer committed Mar 13, 2019
1 parent 7054935 commit dd6afe9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/apollo-env/src/utils/createHash.ts
@@ -1,7 +1,7 @@
import { isNode } from "./isNode";
import { isNodeLike } from "./isNodeLike";

export function createHash(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
2 changes: 1 addition & 1 deletion packages/apollo-env/src/utils/index.ts
@@ -1,2 +1,2 @@
export * from "./createHash";
export * from "./isNode";
export * from "./isNodeLike";
@@ -1,7 +1,6 @@
export const isNode =
export const isNodeLike =
typeof process === "object" &&
process &&
process.release &&
process.release.name === "node" &&
process.versions &&
typeof process.versions.node === "string";

0 comments on commit dd6afe9

Please sign in to comment.