Skip to content

Commit

Permalink
chore(core): add verbose logging temporarily to test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Sep 27, 2022
1 parent b8fd520 commit 86ec6f6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
8 changes: 5 additions & 3 deletions e2e/nx-run/src/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
29 changes: 17 additions & 12 deletions packages/nx/src/utils/lock-file/lock-file.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, writeFileSync } from 'fs';
import { readdirSync, readFileSync, writeFileSync } from 'fs';
import { detectPackageManager, PackageManager } from '../package-manager';
import {
parseYarnLockFile,
Expand All @@ -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);
Expand Down Expand Up @@ -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}`);
Expand Down

0 comments on commit 86ec6f6

Please sign in to comment.