Skip to content

Commit

Permalink
add —use-npm flag to bypass yarn (facebook#3409)
Browse files Browse the repository at this point in the history
* add —use-npm flag to bypass yarn

* add e2e test for —use-npm flag
  • Loading branch information
tabrindle authored and Pavel Zhytko committed Jul 10, 2018
1 parent f559382 commit 8482eb9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const program = new commander.Command(packageJson.name)
'--scripts-version <alternative-package>',
'use a non-standard version of react-scripts'
)
.option('--use-npm')
.allowUnknownOption()
.on('--help', () => {
console.log(` Only ${chalk.green('<project-directory>')} is required.`);
Expand Down Expand Up @@ -133,10 +134,11 @@ createApp(
projectName,
program.verbose,
program.scriptsVersion,
program.useNpm,
hiddenProgram.internalTestingTemplate
);

function createApp(name, verbose, version, template) {
function createApp(name, verbose, version, useNpm, template) {
const root = path.resolve(name);
const appName = path.basename(root);

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

const useYarn = shouldUseYarn();
const useYarn = useNpm ? false : shouldUseYarn();
const originalDirectory = process.cwd();
process.chdir(root);
if (!useYarn && !checkThatNpmCanReadCwd()) {
Expand Down
14 changes: 14 additions & 0 deletions tasks/e2e-installs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ exists node_modules/react-scripts
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
checkDependencies

# ******************************************************************************
# Test --use-npm flag
# ******************************************************************************

cd "$temp_app_path"
create_react_app --use-npm --scripts-version=0.4.0 test-use-npm-flag
cd test-use-npm-flag

# Check corresponding scripts version is installed.
exists node_modules/react-scripts
[ ! -e "yarn.lock" ] && echo "yarn.lock correctly does not exist"
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
checkDependencies

# ******************************************************************************
# Test --scripts-version with a tarball url
# ******************************************************************************
Expand Down

0 comments on commit 8482eb9

Please sign in to comment.