Skip to content

Commit dc133a3

Browse files
clickclickonsaliansu
authored andcommitted
Stage files for commit after ejecting (#5960)
* 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
1 parent 3c9c21a commit dc133a3

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

packages/react-scripts/scripts/eject.js

+21
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ function getGitStatus() {
3838
}
3939
}
4040

41+
function tryGitAdd(appPath) {
42+
try {
43+
spawnSync(
44+
'git',
45+
['add', path.join(appPath, 'config'), path.join(appPath, 'scripts')],
46+
{
47+
stdio: 'inherit',
48+
}
49+
);
50+
51+
return true;
52+
} catch (e) {
53+
return false;
54+
}
55+
}
56+
4157
console.log(
4258
chalk.cyan.bold(
4359
'NOTE: Create React App 2 supports TypeScript, Sass, CSS Modules and more without ejecting: ' +
@@ -310,6 +326,11 @@ inquirer
310326
console.log(green('Ejected successfully!'));
311327
console.log();
312328

329+
if (tryGitAdd(appPath)) {
330+
console.log(cyan('Staged ejected files for commit.'));
331+
console.log();
332+
}
333+
313334
console.log(
314335
green('Please consider sharing why you ejected in this survey:')
315336
);

tasks/e2e-simple.sh

+3
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ verify_module_scope
269269
# Eject...
270270
echo yes | npm run eject
271271

272+
# Test ejected files were staged
273+
test -n "$(git diff --staged --name-only)"
274+
272275
# Test the build
273276
yarn build
274277
# Check for expected output

0 commit comments

Comments
 (0)