Skip to content
Open
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
57 changes: 45 additions & 12 deletions generators/app/tasks/gitInitialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,52 @@ module.exports = function gitInitialization() {
{ cwd: `${process.cwd()}/${this.projectName}` }
],
context: this.options
}).then(() =>
// git push origin master
runCommand({
command: [
'git',
['push', 'origin', 'master'],
{ cwd: `${process.cwd()}/${this.projectName}` }
],
context: this.options
}).then(() => {
spinner.succeed('git ready');
})
.then(() => {
spinner.stop();
return this.prompt([
{
type: 'confirm',
name: 'pushToMaster',
message: 'Do you want to push to master?'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of asking: push to master? I'd change this to ask which branch do you want to use? and use master as default value.
That way the branch to use is customizable and we dont need if (!pushToMaster) {

}
]);
})
.then(({ pushToMaster }) => {
spinner.start();
if (!pushToMaster) {
// git push origin kickoff
return runCommand({
command: [
'git',
['checkout', '-b', 'kickoff'],
{ cwd: `${process.cwd()}/${this.projectName}` }
],
context: this.options
}).then(() => {
runCommand({
command: [
'git',
['push', 'origin', 'kickoff'],
{ cwd: `${process.cwd()}/${this.projectName}` }
],
context: this.options
});
});
}
// git push origin master
return runCommand({
command: [
'git',
['push', 'origin', 'master'],
{ cwd: `${process.cwd()}/${this.projectName}` }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd extract this command as a function that receives the branch name

],
context: this.options
});
})
);
.then(() => {
spinner.succeed('git ready');
});
});
}
});
Expand Down