Skip to content

Commit b6cde3b

Browse files
authored
feat(gatsby-dev-cli): install deps if there are no gatsby deps but --forceInstall was used (#27055)
1 parent cdc6e85 commit b6cde3b

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

packages/gatsby-dev-cli/src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,13 @@ If you prefer to place them in your package.json dependencies instead,
105105
gatsby-dev will pick them up.
106106
`
107107
)
108-
process.exit()
108+
if (!argv.forceInstall) {
109+
process.exit()
110+
} else {
111+
console.log(
112+
`Continuing other dependencies installation due to "--forceInstall" flag`
113+
)
114+
}
109115
}
110116

111117
watch(gatsbyLocation, argv.packages, {

packages/gatsby-dev-cli/src/watch.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,22 @@ async function watch(
140140

141141
if (forceInstall) {
142142
try {
143-
await publishPackagesLocallyAndInstall({
144-
packagesToPublish: allPackagesToWatch,
145-
root,
146-
localPackages,
147-
ignorePackageJSONChanges,
148-
yarnWorkspaceRoot,
149-
})
143+
if (allPackagesToWatch.length > 0) {
144+
await publishPackagesLocallyAndInstall({
145+
packagesToPublish: allPackagesToWatch,
146+
root,
147+
localPackages,
148+
ignorePackageJSONChanges,
149+
yarnWorkspaceRoot,
150+
})
151+
} else {
152+
// run `yarn`
153+
const yarnInstallCmd = [`yarn`]
154+
155+
console.log(`Installing packages from public NPM registry`)
156+
await promisifiedSpawn(yarnInstallCmd)
157+
console.log(`Installation complete`)
158+
}
150159
} catch (e) {
151160
console.log(e)
152161
}

0 commit comments

Comments
 (0)