Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve to real path before checking for path inequality (#17279)
Co-authored-by: Luis Alvarez D <luis@vercel.com> Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
- Loading branch information
1 parent
fad07cc
commit 5c4d0bd
Showing
8 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function About() { | ||
return <div>About us</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function About2() { | ||
return <div>About 2</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Day() { | ||
return <div>Hello Day</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Link from 'next/link' | ||
export default function Home() { | ||
return ( | ||
<div> | ||
Hello World.{' '} | ||
<Link href="/about"> | ||
<a>About</a> | ||
</Link> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* eslint-env jest */ | ||
import { execSync } from 'child_process' | ||
import fs from 'fs-extra' | ||
import path from 'path' | ||
|
||
jest.setTimeout(100 * 1000) | ||
|
||
beforeAll(async () => { | ||
await clean() | ||
}) | ||
|
||
afterAll(async () => { | ||
await clean() | ||
}) | ||
|
||
test('pnpm installs', async () => { | ||
const pnpm = getStdout('yarn bin pnpm') | ||
exec(pnpm + ' init -y') | ||
exec(pnpm + ' add next react react-dom') | ||
await useLocalNextjs() | ||
// exec('pnpm install') | ||
}) | ||
|
||
test('nextjs builds with pnpm', () => { | ||
const pnpx = getStdout(`yarn bin pnpx`) | ||
exec(pnpx + ' next build') | ||
}) | ||
|
||
const exec = (cmd) => { | ||
return execSync(cmd, { | ||
env: process.env, | ||
shell: true, | ||
stdio: 'inherit', | ||
cwd: path.resolve(__dirname, '..'), | ||
}) | ||
} | ||
|
||
const getStdout = (cmd) => { | ||
return execSync(cmd, { | ||
env: process.env, | ||
shell: true, | ||
stdio: 'pipe', | ||
}) | ||
.toString() | ||
.trim() | ||
} | ||
|
||
async function useLocalNextjs() { | ||
// installed nextjs | ||
const nextPath = path.dirname(require.resolve('next/package.json')) | ||
|
||
// repository root | ||
const root = path.dirname( | ||
require.resolve(path.resolve(process.cwd(), 'package.json')) | ||
) | ||
|
||
// local nextjs | ||
const currentNextPath = path.resolve(root, 'packages/next') | ||
|
||
// copy local nextjs to node_modules | ||
await fs.copy( | ||
path.resolve(currentNextPath, 'dist'), | ||
path.resolve(nextPath, 'dist') | ||
) | ||
|
||
console.log('copied local nextjs to node_modules') | ||
} | ||
|
||
async function clean() { | ||
// jest test cannot be found if a package.json exists in test directory | ||
await fs.remove(path.resolve(__dirname, '../package.json')) | ||
await fs.remove(path.resolve(__dirname, '../node_modules')) | ||
await fs.remove(path.resolve(__dirname, '../pnpm-lock.yaml')) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters