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

Allow creating app in existing empty dir #315

Merged
merged 2 commits into from
Mar 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/create-redwood-app/src/create-redwood-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ if (!targetDir) {
}

const newAppDir = path.resolve(process.cwd(), targetDir)
const appDirExists = fs.existsSync(newAppDir)

if (appDirExists && fs.readdirSync(newAppDir).length > 0) {
console.error(`'${newAppDir}' already exists and is not empty.`)
process.exit(1)
}

const createProjectTasks = ({ newAppDir }) => {
const tmpDownloadPath = tmp.tmpNameSync({
Expand All @@ -66,11 +72,8 @@ const createProjectTasks = ({ newAppDir }) => {

return [
{
title: `Creating directory '${newAppDir}'`,
title: `${appDirExists ? 'Using' : 'Creating'} directory '${newAppDir}'`,
task: () => {
if (fs.existsSync(newAppDir)) {
throw new Error(`'${newAppDir}' already exists.`)
}
fs.mkdirSync(newAppDir, { recursive: true })
},
},
Expand Down Expand Up @@ -159,7 +162,7 @@ new Listr(
.then(() => {
// TODO: show helpful out for next steps.
console.log()
console.log(`Thanks for trying out Redwood! We've created '${newAppDir}'`)
console.log(`Thanks for trying out Redwood! We've created your app in '${newAppDir}'`)
console.log()
console.log(
'Inside that directory you can run `yarn rw dev` to start the development server.'
Expand Down