Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Commits
d49ffde4
Unverified
Commit
d49ffde4
authored
7 years ago
by
Dan Abramov
Committed by
GitHub
7 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Fix the E2E script (#3888)
* Fix the E2E script * Delete .git if committing failed
parent
1cf2248c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/react-scripts/scripts/init.js
+21
-7
packages/react-scripts/scripts/init.js
tasks/e2e-kitchensink.sh
+0
-6
tasks/e2e-kitchensink.sh
with
21 additions
and
13 deletions
+21
-13
packages/react-scripts/scripts/init.js
+
21
-
7
View file @
d49ffde4
...
@@ -22,7 +22,7 @@ const spawn = require('react-dev-utils/crossSpawn');
...
@@ -22,7 +22,7 @@ const spawn = require('react-dev-utils/crossSpawn');
const
{
defaultBrowsers
}
=
require
(
'
react-dev-utils/browsersHelper
'
);
const
{
defaultBrowsers
}
=
require
(
'
react-dev-utils/browsersHelper
'
);
const
os
=
require
(
'
os
'
);
const
os
=
require
(
'
os
'
);
function
i
nside
GitRepository
()
{
function
i
sIn
GitRepository
()
{
try
{
try
{
execSync
(
'
git rev-parse --is-inside-work-tree
'
,
{
stdio
:
'
ignore
'
});
execSync
(
'
git rev-parse --is-inside-work-tree
'
,
{
stdio
:
'
ignore
'
});
return
true
;
return
true
;
...
@@ -31,7 +31,7 @@ function insideGitRepository() {
...
@@ -31,7 +31,7 @@ function insideGitRepository() {
}
}
}
}
function
i
nside
MercurialRepository
()
{
function
i
sIn
MercurialRepository
()
{
try
{
try
{
execSync
(
'
hg --cwd . root
'
,
{
stdio
:
'
ignore
'
});
execSync
(
'
hg --cwd . root
'
,
{
stdio
:
'
ignore
'
});
return
true
;
return
true
;
...
@@ -40,22 +40,36 @@ function insideMercurialRepository() {
...
@@ -40,22 +40,36 @@ function insideMercurialRepository() {
}
}
}
}
function
tryGitInit
()
{
function
tryGitInit
(
appPath
)
{
let
didInit
=
false
;
try
{
try
{
execSync
(
'
git --version
'
,
{
stdio
:
'
ignore
'
});
execSync
(
'
git --version
'
,
{
stdio
:
'
ignore
'
});
if
(
isInGitRepository
()
||
isInMercurialRepository
())
{
if
(
insideGitRepository
()
||
insideMercurialRepository
())
{
return
false
;
return
false
;
}
}
execSync
(
'
git init
'
,
{
stdio
:
'
ignore
'
});
execSync
(
'
git init
'
,
{
stdio
:
'
ignore
'
});
didInit
=
true
;
execSync
(
'
git add -A
'
,
{
stdio
:
'
ignore
'
});
execSync
(
'
git add -A
'
,
{
stdio
:
'
ignore
'
});
execSync
(
'
git commit -m "Initial commit from Create React App"
'
,
{
execSync
(
'
git commit -m "Initial commit from Create React App"
'
,
{
stdio
:
'
ignore
'
,
stdio
:
'
ignore
'
,
});
});
return
true
;
return
true
;
}
catch
(
e
)
{
}
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
;
return
false
;
}
}
}
}
...
@@ -172,7 +186,7 @@ module.exports = function(
...
@@ -172,7 +186,7 @@ module.exports = function(
}
}
}
}
if
(
tryGitInit
())
{
if
(
tryGitInit
(
appPath
))
{
console
.
log
();
console
.
log
();
console
.
log
(
'
Initialized a git repository.
'
);
console
.
log
(
'
Initialized a git repository.
'
);
}
}
...
...
This diff is collapsed.
Click to expand it.
tasks/e2e-kitchensink.sh
+
0
-
6
View file @
d49ffde4
...
@@ -174,12 +174,6 @@ rm .babelrc
...
@@ -174,12 +174,6 @@ rm .babelrc
# Finally, let's check that everything still works after ejecting.
# Finally, let's check that everything still works after ejecting.
# ******************************************************************************
# ******************************************************************************
# Commiting changes
git config user.email
"you@example.com"
git config user.name
"Your Name"
git add
.
git commit
-m
"Before npm run eject"
# Eject...
# Eject...
echo yes
| npm run eject
echo yes
| npm run eject
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment