Skip to content

Commit

Permalink
Stage files for commit after ejecting (#5960)
Browse files Browse the repository at this point in the history
* add command to add files to staging after eject

* update console.log message

* wrap git add in a try/catch block

* return true & update log message

* add test to check if files were staged

* Fix check for staged files
  • Loading branch information
clickclickonsal authored and iansu committed Mar 12, 2019
1 parent 3c9c21a commit dc133a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/react-scripts/scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ function getGitStatus() {
}
}

function tryGitAdd(appPath) {
try {
spawnSync(
'git',
['add', path.join(appPath, 'config'), path.join(appPath, 'scripts')],
{
stdio: 'inherit',
}
);

return true;
} catch (e) {
return false;
}
}

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 +326,11 @@ inquirer
console.log(green('Ejected successfully!'));
console.log();

if (tryGitAdd(appPath)) {
console.log(cyan('Staged ejected files for commit.'));
console.log();
}

console.log(
green('Please consider sharing why you ejected in this survey:')
);
Expand Down
3 changes: 3 additions & 0 deletions tasks/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ verify_module_scope
# Eject...
echo yes | npm run eject

# Test ejected files were staged
test -n "$(git diff --staged --name-only)"

# Test the build
yarn build
# Check for expected output
Expand Down

0 comments on commit dc133a3

Please sign in to comment.