From bf97d06b0f16a7375f608e6c05a97547da03a83a Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Fri, 25 Sep 2020 10:50:10 +0200 Subject: [PATCH] feat(gatsby-dev-cli): install deps if there are no gatsby deps but --forceInstall was used --- packages/gatsby-dev-cli/src/index.js | 8 +++++++- packages/gatsby-dev-cli/src/watch.js | 23 ++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/packages/gatsby-dev-cli/src/index.js b/packages/gatsby-dev-cli/src/index.js index 921d254378295..7690a2f28adcb 100644 --- a/packages/gatsby-dev-cli/src/index.js +++ b/packages/gatsby-dev-cli/src/index.js @@ -105,7 +105,13 @@ If you prefer to place them in your package.json dependencies instead, gatsby-dev will pick them up. ` ) - process.exit() + if (!argv.forceInstall) { + process.exit() + } else { + console.log( + `Continuing other dependencies installation due to "--forceInstall" flag` + ) + } } watch(gatsbyLocation, argv.packages, { diff --git a/packages/gatsby-dev-cli/src/watch.js b/packages/gatsby-dev-cli/src/watch.js index 5bc2822913ed7..2e81881806366 100644 --- a/packages/gatsby-dev-cli/src/watch.js +++ b/packages/gatsby-dev-cli/src/watch.js @@ -140,13 +140,22 @@ async function watch( if (forceInstall) { try { - await publishPackagesLocallyAndInstall({ - packagesToPublish: allPackagesToWatch, - root, - localPackages, - ignorePackageJSONChanges, - yarnWorkspaceRoot, - }) + if (allPackagesToWatch.length > 0) { + await publishPackagesLocallyAndInstall({ + packagesToPublish: allPackagesToWatch, + root, + localPackages, + ignorePackageJSONChanges, + yarnWorkspaceRoot, + }) + } else { + // run `yarn` + const yarnInstallCmd = [`yarn`] + + console.log(`Installing packages from public NPM registry`) + await promisifiedSpawn(yarnInstallCmd) + console.log(`Installation complete`) + } } catch (e) { console.log(e) }