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

instanceOf: support Deno #2642

Merged
merged 1 commit into from Jun 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/jsutils/instanceOf.js
Expand Up @@ -11,7 +11,7 @@ declare function instanceOf(

// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
// See: https://webpack.js.org/guides/production/
export default process.env.NODE_ENV === 'production'
export default isProductionEnvironment()
? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
// eslint-disable-next-line no-shadow
function instanceOf(value: mixed, constructor: mixed) {
Expand Down Expand Up @@ -44,3 +44,28 @@ spurious results.`,
}
return false;
};

/* global Deno */
/* :: declare var Deno: any; */

function isProductionEnvironment() {
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
try {
if (process.env.NODE_ENV === 'production') {
return true;
}
} catch (e) {
// ignore
}

// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
try {
if (Deno.env.get('DENO_ENV') === 'production') {
return true;
}
} catch (e) {
// ignore
}

return false;
}