From 3cabdc896111f737a43088cf640dc4842b08d11b Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Wed, 10 Jun 2020 23:48:25 +0300 Subject: [PATCH] instanceOf: support Deno Motivation #2566 --- src/jsutils/instanceOf.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/jsutils/instanceOf.js b/src/jsutils/instanceOf.js index d45b58f0f0..6b7c17576b 100644 --- a/src/jsutils/instanceOf.js +++ b/src/jsutils/instanceOf.js @@ -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) { @@ -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; +}