|
8 | 8 |
|
9 | 9 | import { isJsonObject, json } from '@angular-devkit/core'; |
10 | 10 | import { execSync, spawn } from 'node:child_process'; |
11 | | -import { promises as fs, readdirSync, realpathSync, rmSync } from 'node:fs'; |
| 11 | +import { promises as fs, readFileSync, readdirSync, realpathSync, rmSync } from 'node:fs'; |
12 | 12 | import { tmpdir } from 'node:os'; |
13 | 13 | import { join } from 'node:path'; |
14 | 14 | import { PackageManager } from '../../lib/config/workspace-schema'; |
@@ -233,7 +233,6 @@ export class PackageManagerUtils { |
233 | 233 | } |
234 | 234 |
|
235 | 235 | const filesInRoot = readdirSync(this.context.root); |
236 | | - |
237 | 236 | const hasNpmLock = this.hasLockfile(PackageManager.Npm, filesInRoot); |
238 | 237 | const hasYarnLock = this.hasLockfile(PackageManager.Yarn, filesInRoot); |
239 | 238 | const hasPnpmLock = this.hasLockfile(PackageManager.Pnpm, filesInRoot); |
@@ -311,6 +310,18 @@ export class PackageManagerUtils { |
311 | 310 |
|
312 | 311 | let result: PackageManager | undefined; |
313 | 312 | const { workspace: localWorkspace, globalConfiguration: globalWorkspace } = this.context; |
| 313 | + try { |
| 314 | + const { packageManager } = JSON.parse( |
| 315 | + readFileSync(join(this.context.root, 'package.json'), 'utf-8'), |
| 316 | + ) as { |
| 317 | + packageManager?: string; |
| 318 | + }; |
| 319 | + |
| 320 | + if (packageManager) { |
| 321 | + return packageManager.split('@', 1)[0] as PackageManager; |
| 322 | + } |
| 323 | + } catch {} |
| 324 | + |
314 | 325 | if (localWorkspace) { |
315 | 326 | const project = getProjectByCwd(localWorkspace); |
316 | 327 | if (project) { |
|
0 commit comments