Skip to content

Commit c9af16e

Browse files
committedDec 5, 2024
fix: pnpm can't find the double quotes version
1 parent 216a480 commit c9af16e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
 

‎packages/tools/cli/src/lockfile/index.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { PackageManager } from '../package-manager';
22
import { buildPNPMDepTree } from './pnpm';
33
import { buildNPMDepTree } from './npm';
44
import { buildYarnDepTree } from './yarn';
5-
import fsp from 'fs/promises';
6-
import path from 'path';
5+
import fsp from 'node:fs/promises';
6+
import path from 'node:path';
77

88
export interface PackageLockDeps {
99
[depName: string]: PackageLockDep
@@ -34,10 +34,9 @@ export function buildDepTrees(packageManager: PackageManager, dir: string) {
3434

3535
export async function getPNPMLockfileVersion(dir: string) {
3636
const content = await fsp.readFile(path.resolve(dir, 'pnpm-lock.yaml'), 'utf-8');
37-
const [, lockfileVersion] = content.match(/^lockfileVersion: '?(\d*(?:.\d*)?)'?$/m) ?? [];
37+
const [, lockfileVersion] = (/^lockfileVersion: ["']?(\d*(?:\.\d*)?)["']?$/m.exec(content)) ?? [];
3838

39-
if (!lockfileVersion)
40-
throw new Error(`Can't detect lockfile version`)
39+
if (!lockfileVersion) throw new Error('Can\'t detect lockfile version');
4140

4241
return lockfileVersion;
4342
}

0 commit comments

Comments
 (0)