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
b3527d77
Unverified
Commit
b3527d77
authored
7 years ago
by
Dan Abramov
Committed by
GitHub
7 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Fix git init race condition (#3877)
parent
ab2e0f87
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/react-scripts/scripts/init.js
+19
-19
packages/react-scripts/scripts/init.js
with
19 additions
and
19 deletions
+19
-19
packages/react-scripts/scripts/init.js
+
19
-
19
View file @
b3527d77
...
@@ -40,7 +40,7 @@ function insideMercurialRepository() {
...
@@ -40,7 +40,7 @@ function insideMercurialRepository() {
}
}
}
}
function
g
itInit
()
{
function
tryG
itInit
()
{
try
{
try
{
execSync
(
'
git --version
'
,
{
stdio
:
'
ignore
'
});
execSync
(
'
git --version
'
,
{
stdio
:
'
ignore
'
});
...
@@ -114,23 +114,22 @@ module.exports = function(
...
@@ -114,23 +114,22 @@ module.exports = function(
// Rename gitignore after the fact to prevent npm from renaming it to .npmignore
// Rename gitignore after the fact to prevent npm from renaming it to .npmignore
// See: https://github.com/npm/npm/issues/1862
// See: https://github.com/npm/npm/issues/1862
fs
.
move
(
try
{
path
.
join
(
appPath
,
'
gitignore
'
),
fs
.
moveSync
(
path
.
join
(
appPath
,
'
.gitignore
'
),
path
.
join
(
appPath
,
'
gitignore
'
),
[],
path
.
join
(
appPath
,
'
.gitignore
'
),
err
=>
{
[]
if
(
err
)
{
);
// Append if there's already a `.gitignore` file there
}
catch
(
err
)
{
if
(
err
.
code
===
'
EEXIST
'
)
{
// Append if there's already a `.gitignore` file there
const
data
=
fs
.
readFileSync
(
path
.
join
(
appPath
,
'
gitignore
'
));
if
(
err
.
code
===
'
EEXIST
'
)
{
fs
.
appendFileSync
(
path
.
join
(
appPath
,
'
.gitignore
'
),
data
);
const
data
=
fs
.
readFileSync
(
path
.
join
(
appPath
,
'
gitignore
'
));
fs
.
unlinkSync
(
path
.
join
(
appPath
,
'
gitignore
'
));
fs
.
appendFileSync
(
path
.
join
(
appPath
,
'
.gitignore
'
),
data
);
}
else
{
fs
.
unlinkSync
(
path
.
join
(
appPath
,
'
gitignore
'
));
throw
err
;
}
else
{
}
throw
err
;
}
}
}
);
}
let
command
;
let
command
;
let
args
;
let
args
;
...
@@ -173,8 +172,9 @@ module.exports = function(
...
@@ -173,8 +172,9 @@ module.exports = function(
}
}
}
}
if
(
gitInit
())
{
if
(
tryGitInit
())
{
console
.
log
(
'
Initialized git repository
'
);
console
.
log
();
console
.
log
(
'
Initialized a git repository.
'
);
}
}
// Display the most elegant way to cd.
// Display the most elegant way to cd.
...
...
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