Skip to content

Commit

Permalink
instanceOf: support Deno
Browse files Browse the repository at this point in the history
Motivation #2566
  • Loading branch information
IvanGoncharov committed Jun 10, 2020
1 parent 862adb0 commit 8484e25
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 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,26 @@ spurious results.`,
}
return false;
};

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

function isProductionEnvironment() {
try {
if (process.env.NODE_ENV === 'production') {
return true;
}
} catch (e) {
// ignore
}

try {
if (Deno.env.get('DENO_ENV') === 'production') {
return true;
}
} catch (e) {
// ignore
}

return false;
}

0 comments on commit 8484e25

Please sign in to comment.