Skip to content

Commit

Permalink
feat(gatsby-dev-cli): install deps if there are no gatsby deps but --…
Browse files Browse the repository at this point in the history
…forceInstall was used (#27055)
  • Loading branch information
pieh authored Sep 28, 2020
1 parent cdc6e85 commit b6cde3b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
8 changes: 7 additions & 1 deletion packages/gatsby-dev-cli/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
23 changes: 16 additions & 7 deletions packages/gatsby-dev-cli/src/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit b6cde3b

Please sign in to comment.