Skip to content

Commit

Permalink
fix: fixed dev deps ref and added more debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gemaxim committed Aug 15, 2024
1 parent 097c766 commit 4dd003a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
18 changes: 11 additions & 7 deletions lib/dep-graph-builders/pnpm/build-dep-graph-pnpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
LOCK_FILE_NAME,
} from '../../errors/out-of-sync-error';
import { LockfileType } from '../..';
import * as debugModule from 'debug';

const debug = debugModule('snyk-pnpm-workspaces');

export const buildDepGraphPnpm = async (
lockFileParser: PnpmLockfileParser,
Expand Down Expand Up @@ -48,14 +51,15 @@ export const buildDepGraphPnpm = async (

for (const name of Object.keys(topLevelDeps)) {
if (!extractedTopLevelDeps[name]) {
throw new OpenSourceEcosystems.PnpmOutOfSyncError(
const errMessage =
`Dependency ${name} was not found in ` +
`${LOCK_FILE_NAME[LockfileType.pnpm]}. Your package.json and ` +
`${
LOCK_FILE_NAME[LockfileType.pnpm]
} are probably out of sync. Please run ` +
`"${INSTALL_COMMAND[LockfileType.pnpm]}" and try again.`,
);
`${LOCK_FILE_NAME[LockfileType.pnpm]}. Your package.json and ` +
`${
LOCK_FILE_NAME[LockfileType.pnpm]
} are probably out of sync. Please run ` +
`"${INSTALL_COMMAND[LockfileType.pnpm]}" and try again.`;
debug(errMessage);
throw new OpenSourceEcosystems.PnpmOutOfSyncError(errMessage);
}
topLevelDeps[name].version = extractedTopLevelDeps[name].version;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ export abstract class PnpmLockfileParser {
(depName) =>
(topLevel[depName] = {
name: depName,
version: pkg.dependencies[depName],
isDev: false,
version: pkg.devDependencies[depName],
isDev: true,
}),
);
return topLevel;
Expand Down
3 changes: 3 additions & 0 deletions lib/dep-graph-builders/pnpm/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {
INSTALL_COMMAND,
LOCK_FILE_NAME,
} from '../../errors/out-of-sync-error';
import * as debugModule from 'debug';

const debug = debugModule('snyk-pnpm-workspaces');
export const getPnpmChildNode = (
name: string,
depInfo: { version: string; isDev: boolean },
Expand Down Expand Up @@ -42,6 +44,7 @@ export const getPnpmChildNode = (
LOCK_FILE_NAME[LockfileType.pnpm]
} are probably out of sync. Please run ` +
`"${INSTALL_COMMAND[LockfileType.pnpm]}" and try again.`;
debug(errMessage);
throw new OpenSourceEcosystems.PnpmOutOfSyncError(errMessage);
} else {
return {
Expand Down

0 comments on commit 4dd003a

Please sign in to comment.