From da0cbab7913b59f49b84ee9afd8189cd66dbec43 Mon Sep 17 00:00:00 2001 From: Aadyaa Maddi Date: Wed, 6 Feb 2019 02:40:06 +0800 Subject: [PATCH] fix(gatsby-dev-cli): move package.json file check after pathToRepo handling (#11565) --- packages/gatsby-dev-cli/src/index.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/gatsby-dev-cli/src/index.js b/packages/gatsby-dev-cli/src/index.js index 29aa7f211b8b5..c838471cade5b 100644 --- a/packages/gatsby-dev-cli/src/index.js +++ b/packages/gatsby-dev-cli/src/index.js @@ -36,12 +36,6 @@ You typically only need to configure this once.` const conf = new Configstore(pkg.name) const fs = require(`fs-extra`) -const havePackageJsonFile = fs.existsSync(`package.json`) - -if (!havePackageJsonFile) { - console.error(`Current folder must have a package.json file!`) - process.exit() -} let pathToRepo = argv.setPathToRepo @@ -53,6 +47,13 @@ if (pathToRepo) { process.exit() } +const havePackageJsonFile = fs.existsSync(`package.json`) + +if (!havePackageJsonFile) { + console.error(`Current folder must have a package.json file!`) + process.exit() +} + const gatsbyLocation = conf.get(`gatsby-location`) if (!gatsbyLocation) {