diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 3f850068668..8b3b4b334a6 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -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: ' + @@ -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:') ); diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index c2fc89530a1..15564584d49 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -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