Skip to content
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

Stop yarn error message appearing for Windows users of local-cli #13355

Closed
wants to merge 2 commits into from
Closed
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: 5 additions & 5 deletions local-cli/util/PackageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ const spawnOpts = {
stdin: 'inherit',
};

const projectDir = process.cwd();
const isYarnAvailable =
yarn.getYarnVersionIfAvailable() &&
yarn.isGlobalCliUsingYarn(projectDir);

/**
* Execute npm or yarn command
*
Expand All @@ -30,6 +25,11 @@ const isYarnAvailable =
function callYarnOrNpm(yarnCommand, npmCommand) {
let command;

const projectDir = process.cwd();
const isYarnAvailable =
yarn.getYarnVersionIfAvailable() &&
yarn.isGlobalCliUsingYarn(projectDir);

if (isYarnAvailable) {
command = yarnCommand;
} else {
Expand Down
8 changes: 3 additions & 5 deletions local-cli/util/yarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ function getYarnVersionIfAvailable() {
let yarnVersion;
try {
// execSync returns a Buffer -> convert to string
if (process.platform.startsWith('win')) {
yarnVersion = (execSync('yarn --version').toString() || '').trim();
} else {
yarnVersion = (execSync('yarn --version 2>/dev/null').toString() || '').trim();
}
yarnVersion = (execSync('yarn --version', {
stdio: [ 0, 'pipe', 'ignore', ]
}).toString() || '').trim();
} catch (error) {
return null;
}
Expand Down