Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/flatlock-cmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Examples:
const wsNote = result.workspaceCount > 0 ? ` (${result.workspaceCount} workspaces excluded)` : '';
console.log(`✓ ${result.path}${wsNote}`);
console.log(` count: flatlock=${result.flatlockCount} ${result.source}=${result.comparisonCount}`);
console.log(` sets: equinumerous`);
console.log(` sets: equinumerous\n`);
}
} else {
// Determine if this is a "superset" (flatlock found more, expected for pnpm)
Expand All @@ -203,7 +203,7 @@ Examples:
console.log(`⊃ ${result.path}${wsNote}`);
console.log(` count: flatlock=${result.flatlockCount} ${result.source}=${result.comparisonCount}`);
console.log(` sets: SUPERSET (+${result.onlyInFlatlock.length} reachable deps)`);
console.log(` note: flatlock's reachability analysis found transitive deps pnpm omits`);
console.log(` note: flatlock's reachability analysis found transitive deps pnpm omits\n`);
}
} else {
mismatchCount++;
Expand Down
12 changes: 5 additions & 7 deletions src/compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { tmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import { parseSyml } from '@yarnpkg/parsers';
import yaml from 'js-yaml';
import { detectType, fromPath, Type } from './index.js';
import { collect, detectType, Type } from './index.js';
import { parseYarnBerryKey, parseYarnClassic, parseYarnClassicKey } from './parsers/index.js';
import { parseSpec as parsePnpmSpec } from './parsers/pnpm.js';

Expand Down Expand Up @@ -545,12 +545,10 @@ export async function compare(filepath, options = {}) {
const content = await readFile(filepath, 'utf8');
const type = detectType({ path: filepath, content });

const flatlockSet = new Set();
for await (const dep of fromPath(filepath)) {
if (dep.name && dep.version) {
flatlockSet.add(`${dep.name}@${dep.version}`);
}
}
console.time(`⏱ collect [...]${filepath.slice(-40)}`);
const deps = await collect(filepath);
console.timeEnd(`⏱ collect [...]${filepath.slice(-40)}`);
const flatlockSet = new Set(deps.map(({ name, version }) => `${name}@${version}`));

let comparisonResult;
switch (type) {
Expand Down