|
| 1 | +import { realpathSync } from 'node:fs' |
| 2 | +import path from 'node:path' |
| 3 | + |
| 4 | +import NpmConfig from '@npmcli/config' |
| 5 | +import { |
| 6 | + definitions as npmConfigDefinitions, |
| 7 | + flatten as npmConfigFlatten, |
| 8 | + shorthands as npmConfigShorthands, |
| 9 | + // @ts-ignore |
| 10 | +} from '@npmcli/config/lib/definitions' |
| 11 | + |
1 | 12 | import { debugFn, isDebug } from '@socketsecurity/registry/lib/debug' |
2 | 13 |
|
3 | 14 | import { agentFix } from './agent-fix.mts' |
4 | 15 | import { getCiEnv, getOpenPrsForEnvironment } from './fix-env-helpers.mts' |
5 | 16 | import { getActualTree } from './get-actual-tree.mts' |
6 | 17 | import { getAlertsMapOptions } from './shared.mts' |
| 18 | +import constants from '../../constants.mts' |
7 | 19 | import { |
8 | 20 | Arborist, |
9 | 21 | SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES, |
@@ -57,9 +69,27 @@ export async function npmFix( |
57 | 69 | getAlertsMapOptions({ limit: Math.max(limit, openPrs.length) }), |
58 | 70 | ) |
59 | 71 | } else { |
| 72 | + const npmPath = path.resolve( |
| 73 | + realpathSync(pkgEnvDetails.agentExecPath), |
| 74 | + '../..', |
| 75 | + ) |
| 76 | + const config = new NpmConfig({ |
| 77 | + argv: [], |
| 78 | + cwd: process.cwd(), |
| 79 | + definitions: npmConfigDefinitions, |
| 80 | + // Lazily access constants.execPath. |
| 81 | + execPath: constants.execPath, |
| 82 | + env: process.env, |
| 83 | + flatten: npmConfigFlatten, |
| 84 | + npmPath, |
| 85 | + platform: process.platform, |
| 86 | + shorthands: npmConfigShorthands, |
| 87 | + }) |
| 88 | + await config.load() |
60 | 89 | const arb = new Arborist({ |
61 | 90 | path: pkgEnvDetails.pkgPath, |
62 | 91 | ...SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES, |
| 92 | + config, |
63 | 93 | }) |
64 | 94 | actualTree = await arb.reify() |
65 | 95 | // Calling arb.reify() creates the arb.diff object, nulls-out arb.idealTree, |
|
0 commit comments