Unverified Commit 9f93d340 authored by Julius Marminge's avatar Julius Marminge Committed by GitHub

fix: create-next-app copies files it shouldn't (#43131)

<!--
Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

Closes #43130

This fixes the bug where the CLI copies files it shouldn't, by adding a
`/` separator at the end of the directory name.

Given `examples/next-prisma-starter` and
`examples/next-prisma-starter-websockets`, only files inside the
`examples/next-prisma-starter` will now be copied.

Here is a repo created by the CLI after this fix, using

```bash
# Inside packages/create-next-app
pnpm build
node dist/index.js --example https://github.com/trpc/trpc --example-path examples/next-prisma-starter
```

https://github.com/juliusmarminge/create-next-app-bugfix

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent ed2aa9fd
...@@ -102,7 +102,9 @@ export async function downloadAndExtractRepo( ...@@ -102,7 +102,9 @@ export async function downloadAndExtractRepo(
strip: filePath ? filePath.split('/').length + 1 : 1, strip: filePath ? filePath.split('/').length + 1 : 1,
filter: (p) => filter: (p) =>
p.startsWith( p.startsWith(
`${name}-${branch.replace(/\//g, '-')}${filePath ? `/${filePath}` : ''}` `${name}-${branch.replace(/\//g, '-')}${
filePath ? `/${filePath}/` : '/'
}`
), ),
}) })
......
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