Files
pnpm/pkg-manifest/utils/test/convertEnginesRuntimeToDependencies.test.ts
Zoltan Kochan ff7733ce21 feat: add runtimeOnFail setting (#11277)
* feat: add runtimeOnFail setting

Adds a `runtimeOnFail` config setting ('ignore' | 'warn' | 'error' |
'download') that overrides the `onFail` field on `devEngines.runtime`
and `engines.runtime` in the root project's package.json. This makes
it possible to opt into (or out of) runtime auto-download without
changing the project manifest.

* fix: skip runtime download when version is missing

Without a version, convertEnginesRuntimeToDependencies would write
`runtime:undefined` into the manifest. Warn and skip instead.

* feat: apply runtimeOnFail override during install

The config reader override only mutates the context's rootProjectManifest,
but installDeps reads the manifest fresh via tryReadProjectManifest and
findWorkspaceProjects. Apply the override there too so `runtimeOnFail`
actually affects what gets installed. Adds an e2e test covering both
download and ignore overrides through the real CLI bundle.
2026-04-17 12:00:17 +02:00

36 lines
945 B
TypeScript

import {
applyRuntimeOnFailOverride,
convertEnginesRuntimeToDependencies,
} from '@pnpm/pkg-manifest.utils'
import type { ProjectManifest } from '@pnpm/types'
test('convertEnginesRuntimeToDependencies() skips runtime entries without a version', () => {
const manifest: ProjectManifest = {
devEngines: {
runtime: {
name: 'node',
onFail: 'download',
},
},
}
convertEnginesRuntimeToDependencies(manifest, 'devEngines', 'devDependencies')
expect(manifest.devDependencies).toBeUndefined()
})
test('applyRuntimeOnFailOverride(download) skips runtime entries without a version', () => {
const manifest: ProjectManifest = {
devEngines: {
runtime: {
name: 'node',
},
},
}
applyRuntimeOnFailOverride(manifest, 'download')
expect(manifest.devEngines?.runtime).toMatchObject({ name: 'node', onFail: 'download' })
expect(manifest.devDependencies).toBeUndefined()
})