Skip to content
Merged
Changes from 3 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
19 changes: 19 additions & 0 deletions packages/react-scripts/scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ function getGitStatus() {
}
}

function tryGitAdd(appPath) {
try {
spawnSync(
'git',
['add', path.join(appPath, 'config'), path.join(appPath, 'scripts')],
{
stdio: 'inherit',
}
);
} catch (e) {
return '';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can probably just return instead of returning an empty string. What get's returned if this succeeds?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought about just returning but then I saw we're retuning an empty string on line #37 so I did to keep it consistent.

I forgot to return true so I'll add that in. 😓

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That other function returns a string on success and an empty string on failure. If this function returns true on success then it should return false on failure.

}
}

console.log(
chalk.cyan.bold(
'NOTE: Create React App 2 supports TypeScript, Sass, CSS Modules and more without ejecting: ' +
Expand Down Expand Up @@ -310,6 +324,11 @@ inquirer
console.log(green('Ejected successfully!'));
console.log();

if (tryGitAdd(appPath)) {
console.log(cyan('Added ejected files to Staging for commit.'));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The message can probably just be: Staged ejected files for for commit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for for was a typo. Please remove one of them.

console.log();
}

console.log(
green('Please consider sharing why you ejected in this survey:')
);
Expand Down