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

Git init, add, commit: create-redwood-app #153

Merged
merged 4 commits into from
Feb 27, 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
31 changes: 30 additions & 1 deletion packages/create-redwood-app/src/create-redwood-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const tmpDownloadPath = tmp.tmpNameSync({
postfix: '.zip',
})

// To run any commands, use these to set path for the working dir
const targetDir = String(process.argv.slice(2)).replace(/,/g, '-')
const newAppDir = path.resolve(process.cwd(), targetDir)

Expand Down Expand Up @@ -128,6 +129,34 @@ const tasks = new Listr(
}
},
},
{
title: 'Initialize Git and Add First Commit',
task: (_ctx, task) => {
try {
execa.commandSync('git init', {
shell: true,
cwd: `${targetDir}`,
})
} catch (e) {
task.skip(
'Git not installed. Recommend initializing this directory using `git init`.'
)
}
try {
execa.commandSync(
'git add . && git commit -m "Initialized with Create Readwood App"',
{
shell: true,
cwd: `${targetDir}`,
}
)
} catch (e) {
task.skip(
'Initial git commit failed. Recommend running `git add .` and `git commit -m` '
)
}
},
},
])
},
},
Expand All @@ -148,7 +177,7 @@ const tasks = new Listr(
{
title: '...Redwood planting in progress...',
task: (_ctx, task) => {
task.title = 'Success: Your Redwood is Ready to Grow!'
task.title = 'SUCCESS: Your Redwood is Ready to Grow!'
console.log('')
},
},
Expand Down