Skip to content

Commit

Permalink
fix(create-gatsby,gatsby-cli): Always use --legacy-peer-deps (#37280)
Browse files Browse the repository at this point in the history
* initial

* update gatsby-cli
  • Loading branch information
LekoArts committed Dec 16, 2022
1 parent 86e1685 commit 42a3034
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
11 changes: 10 additions & 1 deletion packages/create-gatsby/src/__tests__/init-starter.ts
Expand Up @@ -149,7 +149,15 @@ describe(`init-starter`, () => {
expect(reporter.panic).not.toBeCalled()
expect(execa).toBeCalledWith(
`npm`,
[`install`, `--loglevel`, `error`, `--color`, `always`],
[
`install`,
`--loglevel`,
`error`,
`--color`,
`always`,
`--legacy-peer-deps`,
`--no-audit`,
],
{ stderr: `inherit` }
)
expect(execa).toBeCalledWith(
Expand All @@ -161,6 +169,7 @@ describe(`init-starter`, () => {
`--color`,
`always`,
`--legacy-peer-deps`,
`--no-audit`,
`one-package`,
],
{ stderr: `inherit` }
Expand Down
13 changes: 10 additions & 3 deletions packages/create-gatsby/src/init-starter.ts
Expand Up @@ -124,7 +124,14 @@ const install = async (
stderr: `inherit`,
}

const config = [`--loglevel`, `error`, `--color`, `always`]
const npmAdditionalCliArgs = [
`--loglevel`,
`error`,
`--color`,
`always`,
`--legacy-peer-deps`,
`--no-audit`,
]

if (pm === `yarn` && checkForYarn()) {
const args = packages.length
Expand All @@ -135,7 +142,7 @@ const install = async (
await execa(`yarnpkg`, args, options)
} else {
await fs.remove(`yarn.lock`)
await execa(`npm`, [`install`, ...config], options)
await execa(`npm`, [`install`, ...npmAdditionalCliArgs], options)
await clearLine()

reporter.success(`Installed Gatsby`)
Expand All @@ -145,7 +152,7 @@ const install = async (

await execa(
`npm`,
[`install`, ...config, `--legacy-peer-deps`, ...packages],
[`install`, ...npmAdditionalCliArgs, ...packages],
options
)
await clearLine()
Expand Down
5 changes: 4 additions & 1 deletion packages/gatsby-cli/src/init-starter.ts
Expand Up @@ -25,6 +25,7 @@ const spawn = (
cmd: string,
options?: execa.Options
): execa.ExecaChildProcess => {
// Split on spaces, tabs, new lines
const [file, ...args] = cmd.split(/\s+/)
return spawnWithArgs(file, args, options)
}
Expand Down Expand Up @@ -115,7 +116,9 @@ const install = async (rootPath: string): Promise<void> => {
await spawn(`yarnpkg`)
} else {
await fs.remove(`yarn.lock`)
await spawn(`npm install`)
await spawn(
`npm install --loglevel error --color always --legacy-peer-deps --no-audit`
)
}
} finally {
process.chdir(prevDir)
Expand Down

0 comments on commit 42a3034

Please sign in to comment.