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

fix(repo): fix silent yarn run on e2e for berry #18340

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions e2e/utils/command-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getNpmMajorVersion,
getPublishedVersion,
getStrippedEnvironmentVariables,
getYarnMajorVersion,
isVerboseE2ERun,
} from './get-env-info';
import { TargetConfiguration } from '@nx/devkit';
Expand Down Expand Up @@ -119,6 +120,7 @@ export function getPackageManagerCommand({
runLerna: string;
} {
const npmMajorVersion = getNpmMajorVersion();
const yarnMajorVersion = getYarnMajorVersion(path);
const publishedVersion = getPublishedVersion();
const isYarnWorkspace = fileExists(join(path, 'package.json'))
? readJson('package.json').workspaces
Expand Down Expand Up @@ -147,14 +149,14 @@ export function getPackageManagerCommand({
} create-nx-workspace@${publishedVersion}`,
run: (script: string, args: string) => `yarn ${script} ${args}`,
runNx: `yarn nx`,
runNxSilent: `yarn --silent nx`,
runNxSilent: +yarnMajorVersion >= 2 ? 'yarn nx' : `yarn --silent nx`,
runUninstalledPackage: 'npx --yes',
install: 'yarn',
ciInstall: 'yarn --frozen-lockfile',
addProd: isYarnWorkspace ? 'yarn add -W' : 'yarn add',
addDev: isYarnWorkspace ? 'yarn add -DW' : 'yarn add -D',
list: 'yarn list --pattern',
runLerna: `yarn --silent lerna`,
runLerna: +yarnMajorVersion >= 2 ? 'yarn lerna' : `yarn --silent lerna`,
},
// Pnpm 3.5+ adds nx to
pnpm: {
Expand Down
16 changes: 16 additions & 0 deletions e2e/utils/get-env-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ export function getNpmMajorVersion(): string {
return npmMajorVersion;
}

export function getYarnMajorVersion(path: string): string {
try {
// this fails if path is not yet created
const [npmMajorVersion] = execSync(`yarn -v`, {
cwd: path,
encoding: 'utf-8',
}).split('.');
return npmMajorVersion;
} catch {
const [npmMajorVersion] = execSync(`yarn -v`, { encoding: 'utf-8' }).split(
'.'
);
return npmMajorVersion;
}
meeroslav marked this conversation as resolved.
Show resolved Hide resolved
}

export function getLatestLernaVersion(): string {
const lernaVersion = execSync(`npm view lerna version`, {
encoding: 'utf-8',
Expand Down