Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/create/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ function main(argv, error = console.error, log = console.log) {
}

// Which package manager will be used in the new project
const pkgMgr = args['packageManager'] || detectRunningUnderYarn() ? 'yarn' : 'npm';
let pkgMgr = args['packageManager'];

if (!pkgMgr) {
pkgMgr = detectRunningUnderYarn() ? 'yarn' : 'npm';
} else if(pkgMgr !== 'yarn' && pkgMgr !== 'npm') {
error('Please select between \'yarn\' and \'npm\' when providing --packageManager');
usage(error);
return 1;
}

log_verbose('Running with', process.argv);
log_verbose('Environment', process.env);
Expand Down
10 changes: 10 additions & 0 deletions packages/create/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ wkspContent = read('default_to_yarn/WORKSPACE');
if (wkspContent.indexOf('yarn_install(') < 0) {
fail('should use yarn by default');
}

exitCode = main(['use_npm_with_yarn', '--packageManager=npm']);
if (exitCode != 0) fail('should be success');
wkspContent = read('use_npm_with_yarn/WORKSPACE');
if (wkspContent.indexOf('npm_install(') < 0) {
fail('should use npm as selected');
}

exitCode = main(['neither_yarn_nor_npm', '--packageManager=foo']);
if (exitCode != 1) fail('should exit 1 when selecting neither \'yarn\' nor \'npm\'');
// TODO: run bazel in the new directory to verify a build works

exitCode = main(['--typescript', 'with_ts'], captureError);
Expand Down