mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-28 09:25:42 +08:00
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
This commit is contained in:
committed by
Ian Sutherland
parent
3c9c21a285
commit
dc133a351f
21
packages/react-scripts/scripts/eject.js
vendored
21
packages/react-scripts/scripts/eject.js
vendored
@@ -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:')
|
||||
);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user