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 3e08fea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 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
37 changes: 21 additions & 16 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 @@ -21,17 +21,22 @@ import { workspaceRoot } from '../workspace-root';
import { join } from 'path';

export function lockFileHash(
packageManager: PackageManager = detectPackageManager()
packageManager: PackageManager = detectPackageManager(workspaceRoot)
): 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 All @@ -46,7 +51,7 @@ export function lockFileHash(
* Parses lock file and maps dependencies and metadata to {@link LockFileData}
*/
export function parseLockFile(
packageManager: PackageManager = detectPackageManager()
packageManager: PackageManager = detectPackageManager(workspaceRoot)
): LockFileData {
if (packageManager === 'yarn') {
const file = readFileSync(join(workspaceRoot, 'yarn.lock'), 'utf8');
Expand All @@ -68,21 +73,21 @@ export function parseLockFile(
*/
export function writeLockFile(
lockFile: LockFileData,
packageManager: PackageManager = detectPackageManager()
packageManager: PackageManager = detectPackageManager(workspaceRoot)
): 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 All @@ -95,7 +100,7 @@ export function writeLockFile(
export function pruneLockFile(
lockFile: LockFileData,
packages: string[],
packageManager: PackageManager = detectPackageManager()
packageManager: PackageManager = detectPackageManager(workspaceRoot)
): LockFileData {
if (packageManager === 'yarn') {
return pruneYarnLockFile(lockFile, packages);
Expand Down

0 comments on commit 3e08fea

Please sign in to comment.