Skip to content

Commit

Permalink
fix(repo): fix silent yarn run on e2e for berry (#18340)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav authored Jul 27, 2023
1 parent e4d2338 commit 4a54141
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
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 [yarnMajorVersion] = execSync(`yarn -v`, {
cwd: path,
encoding: 'utf-8',
}).split('.');
return yarnMajorVersion;
} catch {
const [yarnMajorVersion] = execSync(`yarn -v`, { encoding: 'utf-8' }).split(
'.'
);
return yarnMajorVersion;
}
}

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

1 comment on commit 4a54141

@vercel
Copy link

@vercel vercel bot commented on 4a54141 Jul 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx.dev
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app

Please sign in to comment.