-
-
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
Issue 1394 adding no bin links option #4036
Closed
tdfranklin
wants to merge
2
commits into
facebook:next
from
tdfranklin:issue-1394-adding-no-bin-links-option
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ const program = new commander.Command(packageJson.name) | |
'use a non-standard version of react-scripts' | ||
) | ||
.option('--use-npm') | ||
.option('--no-bin-links') | ||
.allowUnknownOption() | ||
.on('--help', () => { | ||
console.log(` Only ${chalk.green('<project-directory>')} is required.`); | ||
|
@@ -159,10 +160,11 @@ createApp( | |
program.verbose, | ||
program.scriptsVersion, | ||
program.useNpm, | ||
program.binLinks, | ||
hiddenProgram.internalTestingTemplate | ||
); | ||
|
||
function createApp(name, verbose, version, useNpm, template) { | ||
function createApp(name, verbose, version, useNpm, binLinks, template) { | ||
const root = path.resolve(name); | ||
const appName = path.basename(root); | ||
|
||
|
@@ -218,7 +220,16 @@ function createApp(name, verbose, version, useNpm, template) { | |
version = '[email protected]'; | ||
} | ||
} | ||
run(root, appName, version, verbose, originalDirectory, template, useYarn); | ||
run( | ||
root, | ||
appName, | ||
version, | ||
verbose, | ||
binLinks, | ||
originalDirectory, | ||
template, | ||
useYarn | ||
); | ||
} | ||
|
||
function isYarnAvailable() { | ||
|
@@ -235,7 +246,7 @@ function shouldUseYarn(appDir) { | |
return (mono.isYarnWs && mono.isAppIncluded) || isYarnAvailable(); | ||
} | ||
|
||
function install(root, useYarn, dependencies, verbose, isOnline) { | ||
function install(root, useYarn, dependencies, verbose, binLinks, isOnline) { | ||
return new Promise((resolve, reject) => { | ||
let command; | ||
let args; | ||
|
@@ -275,6 +286,10 @@ function install(root, useYarn, dependencies, verbose, isOnline) { | |
args.push('--verbose'); | ||
} | ||
|
||
if (binLinks === false) { | ||
args.push('--no-bin-links'); | ||
} | ||
|
||
const child = spawn(command, args, { stdio: 'inherit' }); | ||
child.on('close', code => { | ||
if (code !== 0) { | ||
|
@@ -293,6 +308,7 @@ function run( | |
appName, | ||
version, | ||
verbose, | ||
binLinks, | ||
originalDirectory, | ||
template, | ||
useYarn | ||
|
@@ -318,9 +334,14 @@ function run( | |
); | ||
console.log(); | ||
|
||
return install(root, useYarn, allDependencies, verbose, isOnline).then( | ||
() => packageName | ||
); | ||
return install( | ||
root, | ||
useYarn, | ||
allDependencies, | ||
verbose, | ||
binLinks, | ||
isOnline | ||
).then(() => packageName); | ||
}) | ||
.then(packageName => { | ||
checkNodeVersion(packageName); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't understand this conditon. Should we not be checking that the binLinks option was passed before adding the argument?
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.
Hey @bondz !
Great question! I was trying to follow the same pattern that you use for --use-npm and --verbose, so I was passing the option down the same way that they were. The reason for checking for it to be false is because of the way commander checks args; if any arg is passed with the --no flag, it will set that process to false by default.
So the way it was requested, it looks like the request was to be able to pass an option to create-react-app for --no-bin-links. So if that option is passed, then it will set process.binLinks to false (which is why I specifically checked for it to be false).
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.
Oh, okay. I understand now. Thanks for clarifying.
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.
No problem! Just let me know if I can help or explain anything else!