-
Notifications
You must be signed in to change notification settings - Fork 994
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
Allow creating app in existing empty dir #315
Conversation
I tried `yarn create redwood-app .` in an empty directory where I wanted the files generated, and got an error saying the dir already exists. I think it should be OK to use an existing directory if it's empty 🙂 I have also moved the error out of the Listr task itself, because it seems Listr is not actually stopping execution of the following tasks. At least, it continues outputting the next tasks' titles, which is confusing: I'd say an early exit for this particular error is acceptable?
This doesn't disturb the flow of a developer, so it's a useful feature to have. Thanks, @olance! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! Thank you!
I think we should handle the uncaught exception and then this is ready for merge.
const appDirExists = fs.existsSync(newAppDir) | ||
|
||
if (appDirExists && fs.readdirSync(newAppDir).length > 0) { | ||
throw new Error(`'${newAppDir}' already exists and is not empty.`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would result in an uncaught exception, it would be better to use a combination of console.log
and process.exit(1)
@peterp thanks, I’ll do that tomorrow 🙂 |
Allow creating app in existing empty dir
I tried
yarn create redwood-app .
in an empty directory where I wanted the files generated, and got an error saying the dir already exists.I think it should be OK to use an existing directory if it's empty 🙂
I have also moved the error out of the Listr task itself, because it seems Listr is not actually stopping execution of the following tasks. At least, it continues outputting the next tasks' titles, which is confusing:
I'd say an early exit for this particular error is acceptable?