-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Create git repository with initial commit #1288
Changes from 9 commits
03435a2
ec1fe18
a721762
66fdb9a
f725934
e61343f
05367bc
b9cfee9
ff65875
7f15e12
bbd5c9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,47 @@ process.on('unhandledRejection', err => { | |
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
const chalk = require('chalk'); | ||
const execSync = require('child_process').execSync; | ||
const spawn = require('react-dev-utils/crossSpawn'); | ||
const { defaultBrowsers } = require('react-dev-utils/browsersHelper'); | ||
const os = require('os'); | ||
|
||
function insideGitRepository() { | ||
try { | ||
execSync('git rev-parse --is-inside-work-tree', {stdio: 'ignore'}); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
function insideMercurialRepository() { | ||
try { | ||
execSync('hg --cwd . root', {stdio: 'ignore'}); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
function gitInit() { | ||
try { | ||
execSync('git --version', {stdio: 'ignore'}); | ||
|
||
if (insideGitRepository() || insideMercurialRepository()) { | ||
return false; | ||
} | ||
|
||
execSync('git init', {stdio: 'ignore'}); | ||
execSync('git add .', {stdio: 'ignore'}); | ||
execSync('git commit -m "Initial commit from Create React App"', {stdio: 'ignore'}); | ||
|
||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
module.exports = function( | ||
appPath, | ||
appName, | ||
|
@@ -104,7 +141,7 @@ module.exports = function( | |
args = ['install', '--save', verbose && '--verbose'].filter(e => e); | ||
} | ||
args.push('react', 'react-dom'); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can remove the space There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
// Install additional template dependencies, if present | ||
const templateDependenciesPath = path.join( | ||
appPath, | ||
|
@@ -134,6 +171,10 @@ module.exports = function( | |
} | ||
} | ||
|
||
if (gitInit()) { | ||
console.log('Initializing git repository'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is done after git initialized so i guess it's better to say git repository initialized rather than initializing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
} | ||
|
||
// Display the most elegant way to cd. | ||
// This needs to handle an undefined originalDirectory for | ||
// backward compatibility with old global-cli's. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be
git add -A
?(infact
git add .
covers create and update but this one feels more inclusive)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sendilkumarn Sure, no problem but there really is no difference. Using
git add -A
is the same asgit add .
with Git 2. With Git 1 it isn't the same but the difference is in deleted files. As this is a newly created repo there is not going to be any deleted files.