Closed cherniavskii closed 4 years ago
As I can see in commit history, directory check was introduced in https://github.com/pikapkg/create-snowpack-app/commit/88c82e8e9623971be36c79e2f3d0de23ca5af61b#diff-d078d18348475d97c2577eed65b1e07cR37 Curious what's the background for it
if it weren't for that check, you could do:
npx create-snowpack-app . --template @snowpack/app-template-react-blank
that check was just a quick implementation to make sure that you weren't clobbering files. If you can replace it with a check that folder doesn't exist OR folder exists but is empty, I'd love a PR
See, when there already is initiated repo, checking if directory is empty won't help much, since it has at least .git
, and maybe .gitignore
or README.md
.
What do you think about adding a flag to force install in existing directory? Something like:
$ npx create-snowpack-app . --template @snowpack/app-template-react-blank
. already exists. Use `--force` flag to overwrite files.
oh... yea this i'm much more nervous about. A --force
flag would help a bit with the risk, but I'd rather tackle this post v2.0 release. fwiw Create React App doesn't support this today, I'd also want to see if they ever discussed it in their repo and what their pros/cons were.
Create React App doesn't support this today
Actually it does. Looks like it has a blacklist of files/dirs it checks before installing. For example:
$ ls -a
./ ../ .git/ .gitignore README.md node_modules/
$ npx create-react-app .
npx: installed 98 in 5.23s
The directory . contains files that could conflict:
node_modules/
Either try using a new directory name, or remove the files listed above
$ rm -rf node_modules/
$ npx create-react-app .
# now installs without errors
I like their solution, but it seems a little overkill to me TBH
Nice! Okay, this makes me feel a bit better about it. any interest in creating a PR to add?
Yeah, I'll submit a PR later!
Great!
Hi! 👋
I wanted to check out create-snowpack-app - it looks very promising!
So I've created a new repo on GitHub and checked it out locally. Unfortunately,
create-snowpack-app
doesn't allow to create app in existing directory, which is a little annoying.Would you accept a PR, which will allow to create project in existing directory? I'll be happy to contribute :)
Cheers!