Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix create-next-app failing without yarn installed #35608

Merged
merged 1 commit into from Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/create-next-app/index.ts
Expand Up @@ -129,7 +129,7 @@ async function run(): Promise<void> {
? 'npm'
: !!program.usePnpm
? 'pnpm'
: 'yarn'
: getPkgManager()

const example = typeof program.example === 'string' && program.example.trim()
try {
Expand Down
25 changes: 24 additions & 1 deletion test/integration/create-next-app/index.test.ts
Expand Up @@ -305,7 +305,30 @@ describe('create next app', () => {

it('should create a project in the current directory', async () => {
await usingTempDir(async (cwd) => {
const res = await run(['.'], { cwd })
const env = { ...process.env }
const tmpBin = path.join(__dirname, 'bin')
const tmpYarn = path.join(tmpBin, 'yarn')

if (process.platform !== 'win32') {
// ensure install succeeds with invalid yarn binary
// which simulates no yarn binary being available as
// an alternative to removing the binary and reinstalling
await fs.remove(tmpBin)
await fs.mkdir(tmpBin)
await fs.writeFile(tmpYarn, '#!/bin/sh\nexit 1')
await fs.chmod(tmpYarn, '755')
env.PATH = `${tmpBin}:${env.PATH}`
delete env.npm_config_user_agent
}

const res = await run(['.'], {
cwd,
env,
extendEnv: false,
stdio: 'inherit',
})
await fs.remove(tmpBin)

expect(res.exitCode).toBe(0)

const files = [
Expand Down