mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-15 09:33:45 -05:00
fix: don't remove ignored builds list on repeat install (#9083)
close #9045
This commit is contained in:
7
.changeset/few-ducks-agree.md
Normal file
7
.changeset/few-ducks-agree.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@pnpm/headless": patch
|
||||
"@pnpm/build-modules": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
`pnpm approve-builds` should work after two consecutive `pnpm install` runs [#9083](https://github.com/pnpm/pnpm/pull/9083).
|
||||
@@ -45,7 +45,8 @@ export async function buildModules<T extends string> (
|
||||
rootModulesDir: string
|
||||
hoistedLocations?: Record<string, string[]>
|
||||
}
|
||||
): Promise<{ ignoredBuilds: string[] }> {
|
||||
): Promise<{ ignoredBuilds?: string[] }> {
|
||||
if (!rootDepPaths.length) return {}
|
||||
const warn = (message: string) => {
|
||||
logger.warn({ message, prefix: opts.lockfileDir })
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
WANTED_LOCKFILE,
|
||||
} from '@pnpm/constants'
|
||||
import {
|
||||
ignoredScriptsLogger,
|
||||
packageManifestLogger,
|
||||
progressLogger,
|
||||
stageLogger,
|
||||
@@ -46,6 +47,7 @@ import {
|
||||
import { prune } from '@pnpm/modules-cleaner'
|
||||
import {
|
||||
type IncludedDependencies,
|
||||
type Modules,
|
||||
writeModulesManifest,
|
||||
} from '@pnpm/modules-yaml'
|
||||
import { type HoistingLimits } from '@pnpm/real-hoist'
|
||||
@@ -174,6 +176,7 @@ export interface HeadlessOptions {
|
||||
useLockfile?: boolean
|
||||
supportedArchitectures?: SupportedArchitectures
|
||||
hoistWorkspacePackages?: boolean
|
||||
modulesFile?: Modules | null
|
||||
}
|
||||
|
||||
export interface InstallationResultStats {
|
||||
@@ -547,6 +550,10 @@ export async function headlessInstall (opts: HeadlessOptions): Promise<Installat
|
||||
unsafePerm: opts.unsafePerm,
|
||||
userAgent: opts.userAgent,
|
||||
})).ignoredBuilds
|
||||
if (ignoredBuilds == null && opts.modulesFile?.ignoredBuilds?.length) {
|
||||
ignoredBuilds = opts.modulesFile.ignoredBuilds
|
||||
ignoredScriptsLogger.debug({ packageNames: ignoredBuilds })
|
||||
}
|
||||
}
|
||||
|
||||
const projectsToBeBuilt = extendProjectsWithTargetDirs(selectedProjects, wantedLockfile, {
|
||||
|
||||
@@ -303,3 +303,15 @@ test('throw an error when strict-dep-builds is true and there are ignored script
|
||||
'@pnpm.e2e/pre-and-postinstall-scripts-example': '1.0.0',
|
||||
})
|
||||
})
|
||||
|
||||
test('the list of ignored builds is preserved after a repeat install', async () => {
|
||||
const project = prepare({})
|
||||
execPnpmSync(['add', '@pnpm.e2e/pre-and-postinstall-scripts-example@1.0.0', '--config.optimistic-repeat-install=false'])
|
||||
|
||||
const result = execPnpmSync(['install'])
|
||||
// The warning is printed on repeat install too
|
||||
expect(result.stdout.toString()).toContain('Ignored build scripts:')
|
||||
|
||||
const modulesManifest = project.readModulesManifest()
|
||||
expect(modulesManifest?.ignoredBuilds).toStrictEqual(['@pnpm.e2e/pre-and-postinstall-scripts-example'])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user