-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Beaufity output of eject.js script #769
Changes from 1 commit
350b2bc
822ad8c
bfe4850
1c5f505
173e87c
41345b7
259b6f5
52b7123
917404e
1a8ff9e
4b9fa8a
f6f635d
79a4c2b
c440b27
52c432f
308a21e
2e208c9
40fa310
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 |
---|---|---|
|
@@ -13,13 +13,16 @@ var path = require('path'); | |
var prompt = require('react-dev-utils/prompt'); | ||
var rimrafSync = require('rimraf').sync; | ||
var spawnSync = require('cross-spawn').sync; | ||
var chalk = require('chalk'); | ||
var green = chalk.green; | ||
var yellowUnderline = chalk.yellow.underline | ||
|
||
prompt( | ||
'Are you sure you want to eject? This action is permanent.', | ||
false | ||
).then(shouldEject => { | ||
if (!shouldEject) { | ||
console.log('Close one! Eject aborted.'); | ||
console.log(green('Close one! Eject aborted.')); | ||
process.exit(1); | ||
} | ||
|
||
|
@@ -62,7 +65,7 @@ prompt( | |
fs.mkdirSync(path.join(appPath, 'scripts')); | ||
|
||
files.forEach(function(file) { | ||
console.log('Copying ' + file + ' to ' + appPath); | ||
console.log(green('Copying ') + yellowUnderline(file) + ' to ' + yellowUnderline(appPath)); | ||
var content = fs | ||
.readFileSync(path.join(ownPath, file), 'utf8') | ||
// Remove dead code from .js files on eject | ||
|
@@ -78,15 +81,15 @@ prompt( | |
var appPackage = require(path.join(appPath, 'package.json')); | ||
|
||
var ownPackageName = ownPackage.name; | ||
console.log('Removing dependency: ' + ownPackageName); | ||
console.log('Removing dependency: ' + yellowUnderline(ownPackageName)); | ||
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. I think this should have the same indentation as “adding a dependency” but they both need to be grouped under “Updating |
||
delete appPackage.devDependencies[ownPackageName]; | ||
|
||
Object.keys(ownPackage.dependencies).forEach(function (key) { | ||
// For some reason optionalDependencies end up in dependencies after install | ||
if (ownPackage.optionalDependencies[key]) { | ||
return; | ||
} | ||
console.log('Adding dependency: ' + key); | ||
console.log(green('\tAdding dependency: ') + yellowUnderline(key)); | ||
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. Let’s use two-space indentation like in other commands. |
||
appPackage.devDependencies[key] = ownPackage.dependencies[key]; | ||
}); | ||
|
||
|
@@ -107,20 +110,20 @@ prompt( | |
true | ||
); | ||
|
||
console.log('Writing package.json'); | ||
console.log(green('Writing ') + yellowUnderline('package.json')); | ||
fs.writeFileSync( | ||
path.join(appPath, 'package.json'), | ||
JSON.stringify(appPackage, null, 2) | ||
); | ||
console.log(); | ||
|
||
console.log('Running npm install...'); | ||
console.log(green('Running ') + yellowUnderline('npm install...')); | ||
rimrafSync(ownPath); | ||
spawnSync('npm', ['install'], {stdio: 'inherit'}); | ||
console.log('Ejected successfully!'); | ||
console.log(green('Ejected successfully!')); | ||
console.log(); | ||
|
||
console.log('Please consider sharing why you ejected in this survey:'); | ||
console.log(' http://goo.gl/forms/Bi6CZjk1EqsdelXk1'); | ||
console.log(); | ||
}); | ||
console.log(green('Please consider sharing why you ejected in this survey:')); | ||
console.log('\t' + yellowUnderline('http://goo.gl/forms/Bi6CZjk1EqsdelXk1')); | ||
console.log() | ||
}) |
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.
Let’s indent these and group them under “Copying files...”