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:
Salvador Hernandez
2019-03-12 00:06:37 -04:00
committed by Ian Sutherland
parent 3c9c21a285
commit dc133a351f
2 changed files with 24 additions and 0 deletions

View File

@@ -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:')
);

View File

@@ -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