Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the E2E script #3888

Merged
merged 2 commits into from
Jan 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions packages/react-scripts/scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const spawn = require('react-dev-utils/crossSpawn');
const { defaultBrowsers } = require('react-dev-utils/browsersHelper');
const os = require('os');

function insideGitRepository() {
function isInGitRepository() {
try {
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
return true;
Expand All @@ -31,7 +31,7 @@ function insideGitRepository() {
}
}

function insideMercurialRepository() {
function isInMercurialRepository() {
try {
execSync('hg --cwd . root', { stdio: 'ignore' });
return true;
Expand All @@ -40,22 +40,36 @@ function insideMercurialRepository() {
}
}

function tryGitInit() {
function tryGitInit(appPath) {
let didInit = false;
try {
execSync('git --version', { stdio: 'ignore' });

if (insideGitRepository() || insideMercurialRepository()) {
if (isInGitRepository() || isInMercurialRepository()) {
return false;
}

execSync('git init', { stdio: 'ignore' });
didInit = true;

execSync('git add -A', { stdio: 'ignore' });
execSync('git commit -m "Initial commit from Create React App"', {
stdio: 'ignore',
});

return true;
} catch (e) {
if (didInit) {
// If we successfully initialized but couldn't commit,
// maybe the commit author config is not set.
// In the future, we might supply our own committer
// like Ember CLI does, but for now, let's just
// remove the Git files to avoid a half-done state.
try {
// unlinkSync() doesn't work on directories.
fs.removeSync(path.join(appPath, '.git'));
} catch (removeErr) {
// Ignore.
}
}
return false;
}
}
Expand Down Expand Up @@ -172,7 +186,7 @@ module.exports = function(
}
}

if (tryGitInit()) {
if (tryGitInit(appPath)) {
console.log();
console.log('Initialized a git repository.');
}
Expand Down
6 changes: 0 additions & 6 deletions tasks/e2e-kitchensink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,6 @@ rm .babelrc
# Finally, let's check that everything still works after ejecting.
# ******************************************************************************

# Commiting changes
git config user.email "[email protected]"
git config user.name "Your Name"
git add .
git commit -m "Before npm run eject"

# Eject...
echo yes | npm run eject

Expand Down