diff --git a/lib/utils/api-runner-browser.js b/lib/utils/api-runner-browser.js index 6cc5ad47d7965..3426858c4018a 100644 --- a/lib/utils/api-runner-browser.js +++ b/lib/utils/api-runner-browser.js @@ -1,20 +1,17 @@ const Promise = require(`bluebird`) const path = require(`path`) import invariant from 'invariant' -import _ from 'lodash' module.exports = (api, args, defaultReturn) => { let gatsbyBrowser try { gatsbyBrowser = require(`gatsby-browser`) } catch (e) { - console.log('error', e) - if (e.code !== `MODULE_NOT_FOUND` && !_.includes(e.Error, `gatsby-browser`)) { + if (e.toString().indexOf(`gatsby-browser`) !== -1) { console.log(`Couldn't open your gatsby-browser.js file`) console.log(e) } } - console.log('gatsbyBrowser module + api', gatsbyBrowser, api) if (gatsbyBrowser && gatsbyBrowser[api]) { const result = gatsbyBrowser[api](args) if (!result) { diff --git a/lib/utils/api-runner-node.js b/lib/utils/api-runner-node.js index abbb1f1921e5c..8f9160a8fa82d 100644 --- a/lib/utils/api-runner-node.js +++ b/lib/utils/api-runner-node.js @@ -2,15 +2,15 @@ const Promise = require(`bluebird`) const path = require(`path`) import invariant from 'invariant' import _ from 'lodash' +import chalk from 'chalk' module.exports = async (api, args, defaultReturn) => { let gatsbyNode try { gatsbyNode = require(`${path.resolve(`.`)}/gatsby-node`) } catch (e) { - console.log('error', e) - if (e.code !== `MODULE_NOT_FOUND` && !_.includes(e.Error, `gatsby-node`)) { - console.log(`Couldn't open your gatsby-node.js file`) + if (/*e.code !== `MODULE_NOT_FOUND` &&*/ !_.includes(e.toString(), `gatsby-node`)) { + console.log(chalk.bold.red(`Couldn't open your gatsby-node.js file`)) console.log(e) } } diff --git a/lib/utils/api-runner-ssr.js b/lib/utils/api-runner-ssr.js index 630c3b5728c6c..3e179db9362e2 100644 --- a/lib/utils/api-runner-ssr.js +++ b/lib/utils/api-runner-ssr.js @@ -8,7 +8,7 @@ module.exports = (api, args, defaultReturn) => { try { gatsbySSR = require(`gatsby-ssr`) } catch (e) { - if (e.code !== `MODULE_NOT_FOUND` && !_.includes(e.Error, `gatsby-browser`)) { + if (/*e.code !== `MODULE_NOT_FOUND` &&*/ !_.includes(e.toString(), `gatsby-ssr`)) { console.log(`Couldn't open your gatsby-browser.js file`) console.log(e) }