Unverified Commit e30d7237 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Ensure older lockfile/invalid formats are handled (#36577)

parent 486040ef
......@@ -19,15 +19,15 @@ export async function patchIncorrectLockfile(dir: string) {
const content = await promises.readFile(lockfilePath, 'utf8')
const lockfileParsed = JSON.parse(content)
const packageKeys = Object.keys(lockfileParsed.dependencies)
const foundSwcPkgs = new Set()
const nextPkg = lockfileParsed.packages['node_modules/next']
const nextPkg = lockfileParsed.packages?.['node_modules/next']
// if we don't find next in the package-lock we can't continue
if (!nextPkg) {
return
}
const nextVersion = nextPkg.version
const packageKeys = Object.keys(lockfileParsed.dependencies || {})
const expectedSwcPkgs = Object.keys(nextPkg?.optionalDependencies).filter(
(pkg) => pkg.startsWith('@next/swc-')
......
......@@ -40,12 +40,18 @@ describe('dependencies can use env vars in middlewares', () => {
})
}
`,
// make sure invalid package-lock doesn't error
'package-lock.json': '{}',
},
dependencies: {},
})
})
afterAll(() => next.destroy())
it('does not error from patching lockfile', () => {
expect(next.cliOutput).not.toContain('patch-incorrect-lockfile')
})
it('parses the env vars correctly', async () => {
const testDir = next.testDir
const manifestPath = path.join(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment