Unverified Commit b3527d77 authored by Dan Abramov's avatar Dan Abramov Committed by GitHub
Browse files

Fix git init race condition (#3877)

parent ab2e0f87
3 merge requests!12191Lim.Pisey.168:/Identified - We are currently investigating reports of missing build logs. The issue has been identified and a resolution is in progress. We will provide a further update when available.Mar 21, 09:02 UTC,!12853brikk,!5717Automatically extract project file structure from build bundle file
Showing with 19 additions and 19 deletions
+19 -19
......@@ -40,7 +40,7 @@ function insideMercurialRepository() {
}
}
function gitInit() {
function tryGitInit() {
try {
execSync('git --version', { stdio: 'ignore' });
......@@ -114,23 +114,22 @@ module.exports = function(
// Rename gitignore after the fact to prevent npm from renaming it to .npmignore
// See: https://github.com/npm/npm/issues/1862
fs.move(
path.join(appPath, 'gitignore'),
path.join(appPath, '.gitignore'),
[],
err => {
if (err) {
// Append if there's already a `.gitignore` file there
if (err.code === 'EEXIST') {
const data = fs.readFileSync(path.join(appPath, 'gitignore'));
fs.appendFileSync(path.join(appPath, '.gitignore'), data);
fs.unlinkSync(path.join(appPath, 'gitignore'));
} else {
throw err;
}
}
try {
fs.moveSync(
path.join(appPath, 'gitignore'),
path.join(appPath, '.gitignore'),
[]
);
} catch (err) {
// Append if there's already a `.gitignore` file there
if (err.code === 'EEXIST') {
const data = fs.readFileSync(path.join(appPath, 'gitignore'));
fs.appendFileSync(path.join(appPath, '.gitignore'), data);
fs.unlinkSync(path.join(appPath, 'gitignore'));
} else {
throw err;
}
);
}
let command;
let args;
......@@ -173,8 +172,9 @@ module.exports = function(
}
}
if (gitInit()) {
console.log('Initialized git repository');
if (tryGitInit()) {
console.log();
console.log('Initialized a git repository.');
}
// Display the most elegant way to cd.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment