diff --git a/bin/flatlock-cmp.js b/bin/flatlock-cmp.js index b999a3d..4a10b6a 100755 --- a/bin/flatlock-cmp.js +++ b/bin/flatlock-cmp.js @@ -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) @@ -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++; diff --git a/src/compare.js b/src/compare.js index 4a1dd28..34624e7 100644 --- a/src/compare.js +++ b/src/compare.js @@ -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'; @@ -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) {