From 86ec6f67051b0b2e17a4cd51009beff94e3c183a Mon Sep 17 00:00:00 2001 From: Miroslav Jonas Date: Tue, 27 Sep 2022 15:44:27 +0200 Subject: [PATCH] chore(core): add verbose logging temporarily to test failure --- e2e/nx-run/src/run.test.ts | 8 ++++-- packages/nx/src/utils/lock-file/lock-file.ts | 29 ++++++++++++-------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/e2e/nx-run/src/run.test.ts b/e2e/nx-run/src/run.test.ts index 9ed8924ac2bbb8..9a76fb311a469b 100644 --- a/e2e/nx-run/src/run.test.ts +++ b/e2e/nx-run/src/run.test.ts @@ -206,9 +206,11 @@ describe('Nx Running Tests', () => { runCLI(`generate @nrwl/web:app ${myapp}`); // Should work within the project directory - expect(runCommand(`cd apps/${myapp}/src && npx nx build`)).toContain( - `nx run ${myapp}:build:production` - ); + expect( + runCommand( + `cd apps/${myapp}/src && NX_VERBOSE_LOGGING=true npx nx build --verbose` + ) + ).toContain(`nx run ${myapp}:build:production`); }, 10000); describe('target dependencies', () => { diff --git a/packages/nx/src/utils/lock-file/lock-file.ts b/packages/nx/src/utils/lock-file/lock-file.ts index a49f3ea595ad2d..c2a301bc5ee76b 100644 --- a/packages/nx/src/utils/lock-file/lock-file.ts +++ b/packages/nx/src/utils/lock-file/lock-file.ts @@ -1,4 +1,4 @@ -import { readFileSync, writeFileSync } from 'fs'; +import { readdirSync, readFileSync, writeFileSync } from 'fs'; import { detectPackageManager, PackageManager } from '../package-manager'; import { parseYarnLockFile, @@ -24,14 +24,19 @@ export function lockFileHash( packageManager: PackageManager = detectPackageManager() ): string { let file: string; - if (packageManager === 'yarn') { - file = readFileSync(join(workspaceRoot, 'yarn.lock'), 'utf8'); - } - if (packageManager === 'pnpm') { - file = readFileSync(join(workspaceRoot, 'pnpm-lock.yaml'), 'utf8'); - } - if (packageManager === 'npm') { - file = readFileSync(join(workspaceRoot, 'package-lock.json'), 'utf8'); + try { + if (packageManager === 'yarn') { + file = readFileSync(join(workspaceRoot, 'yarn.lock'), 'utf8'); + } + if (packageManager === 'pnpm') { + file = readFileSync(join(workspaceRoot, 'pnpm-lock.yaml'), 'utf8'); + } + if (packageManager === 'npm') { + file = readFileSync(join(workspaceRoot, 'package-lock.json'), 'utf8'); + } + } catch (e) { + console.log(readdirSync(workspaceRoot, { encoding: 'utf-8' })); + throw e; } if (file) { return hashLockFile(file); @@ -72,17 +77,17 @@ export function writeLockFile( ): void { if (packageManager === 'yarn') { const content = stringifyYarnLockFile(lockFile); - writeFileSync('yarn.lock', content); + writeFileSync(join(workspaceRoot, 'yarn.lock'), content); return; } if (packageManager === 'pnpm') { const content = stringifyPnpmLockFile(lockFile); - writeFileSync('pnpm-lock.yaml', content); + writeFileSync(join(workspaceRoot, 'pnpm-lock.yaml'), content); return; } if (packageManager === 'npm') { const content = stringifyNpmLockFile(lockFile); - writeFileSync('package-lock.json', content); + writeFileSync(join(workspaceRoot, 'package-lock.json'), content); return; } throw Error(`Unknown package manager: ${packageManager}`);