Skip to content

Commit c8ca0d0

Browse files
tabrindleplacenamehere
authored andcommitted
add —use-npm flag to bypass yarn (facebook#3409)
* add —use-npm flag to bypass yarn * add e2e test for —use-npm flag
1 parent 15c014e commit c8ca0d0

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/create-react-app/createReactApp.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const program = new commander.Command(packageJson.name)
6464
'--scripts-version <alternative-package>',
6565
'use a non-standard version of react-scripts'
6666
)
67+
.option('--use-npm')
6768
.allowUnknownOption()
6869
.on('--help', () => {
6970
console.log(` Only ${chalk.green('<project-directory>')} is required.`);
@@ -133,10 +134,11 @@ createApp(
133134
projectName,
134135
program.verbose,
135136
program.scriptsVersion,
137+
program.useNpm,
136138
hiddenProgram.internalTestingTemplate
137139
);
138140

139-
function createApp(name, verbose, version, template) {
141+
function createApp(name, verbose, version, useNpm, template) {
140142
const root = path.resolve(name);
141143
const appName = path.basename(root);
142144

@@ -159,7 +161,7 @@ function createApp(name, verbose, version, template) {
159161
JSON.stringify(packageJson, null, 2)
160162
);
161163

162-
const useYarn = shouldUseYarn();
164+
const useYarn = useNpm ? false : shouldUseYarn();
163165
const originalDirectory = process.cwd();
164166
process.chdir(root);
165167
if (!useYarn && !checkThatNpmCanReadCwd()) {

tasks/e2e-installs.sh

+14
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,20 @@ exists node_modules/react-scripts
145145
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
146146
checkDependencies
147147

148+
# ******************************************************************************
149+
# Test --use-npm flag
150+
# ******************************************************************************
151+
152+
cd "$temp_app_path"
153+
create_react_app --use-npm --scripts-version=0.4.0 test-use-npm-flag
154+
cd test-use-npm-flag
155+
156+
# Check corresponding scripts version is installed.
157+
exists node_modules/react-scripts
158+
[ ! -e "yarn.lock" ] && echo "yarn.lock correctly does not exist"
159+
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
160+
checkDependencies
161+
148162
# ******************************************************************************
149163
# Test --scripts-version with a tarball url
150164
# ******************************************************************************

0 commit comments

Comments
 (0)