mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-24 23:58:07 -05:00
feat: ignore-dep-scripts (#5142)
This commit is contained in:
8
.changeset/real-carrots-hide.md
Normal file
8
.changeset/real-carrots-hide.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
"@pnpm/config": minor
|
||||
"@pnpm/core": minor
|
||||
"@pnpm/headless": minor
|
||||
"pnpm": minor
|
||||
---
|
||||
|
||||
When `ignore-dep-scripts` is `true`, ignore scripts of dependencies but run the scripts of the project.
|
||||
@@ -27,6 +27,7 @@ export interface Config {
|
||||
global?: boolean
|
||||
dir: string
|
||||
bin: string
|
||||
ignoreDepScripts?: boolean
|
||||
ignoreScripts?: boolean
|
||||
ignoreCompatibilityDb?: boolean
|
||||
includeWorkspaceRoot?: boolean
|
||||
|
||||
@@ -61,6 +61,7 @@ export const types = Object.assign({
|
||||
hoist: Boolean,
|
||||
'hoist-pattern': Array,
|
||||
'ignore-compatibility-db': Boolean,
|
||||
'ignore-dep-scripts': Boolean,
|
||||
'ignore-pnpmfile': Boolean,
|
||||
'ignore-workspace': Boolean,
|
||||
'ignore-workspace-root-check': Boolean,
|
||||
|
||||
@@ -33,6 +33,7 @@ export interface StrictInstallOptions {
|
||||
lockfileOnly: boolean
|
||||
fixLockfile: boolean
|
||||
ignoreCompatibilityDb: boolean
|
||||
ignoreDepScripts: boolean
|
||||
ignorePackageManifest: boolean
|
||||
preferFrozenLockfile: boolean
|
||||
saveWorkspaceProtocol: boolean | 'rolling'
|
||||
@@ -131,6 +132,7 @@ const defaults = async (opts: InstallOptions) => {
|
||||
publicHoistPattern: undefined,
|
||||
hooks: {},
|
||||
ignoreCurrentPrefs: false,
|
||||
ignoreDepScripts: false,
|
||||
ignoreScripts: false,
|
||||
include: {
|
||||
dependencies: true,
|
||||
|
||||
@@ -947,7 +947,7 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
|
||||
extraBinPaths: ctx.extraBinPaths,
|
||||
extraNodePaths: ctx.extraNodePaths,
|
||||
extraEnv,
|
||||
ignoreScripts: opts.ignoreScripts,
|
||||
ignoreScripts: opts.ignoreScripts || opts.ignoreDepScripts,
|
||||
lockfileDir: ctx.lockfileDir,
|
||||
optional: opts.include.optionalDependencies,
|
||||
preferSymlinkedExecutables: opts.preferSymlinkedExecutables,
|
||||
|
||||
@@ -618,3 +618,41 @@ test('lifecycle scripts run after linking root dependencies', async () => {
|
||||
|
||||
// if there was no exception, the test passed
|
||||
})
|
||||
|
||||
test('ignore-dep-scripts', async () => {
|
||||
prepareEmpty()
|
||||
const manifest = {
|
||||
scripts: {
|
||||
'pnpm:devPreinstall': 'node -e "require(\'fs\').writeFileSync(\'test.txt\', \'\', \'utf-8\')"',
|
||||
install: 'node -e "process.stdout.write(\'install\')" | json-append output.json',
|
||||
postinstall: 'node -e "process.stdout.write(\'postinstall\')" | json-append output.json',
|
||||
preinstall: 'node -e "process.stdout.write(\'preinstall\')" | json-append output.json',
|
||||
},
|
||||
dependencies: {
|
||||
'json-append': '1.1.1',
|
||||
'pre-and-postinstall-scripts-example': '1.0.0',
|
||||
},
|
||||
}
|
||||
await install(manifest, await testDefaults({ fastUnpack: false, ignoreDepScripts: true }))
|
||||
|
||||
{
|
||||
const output = await loadJsonFile<string[]>('output.json')
|
||||
|
||||
expect(output).toStrictEqual(['preinstall', 'install', 'postinstall'])
|
||||
expect(await exists('test.txt')).toBeTruthy()
|
||||
|
||||
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
|
||||
}
|
||||
|
||||
await rimraf('node_modules')
|
||||
await rimraf('output.json')
|
||||
await install(manifest, await testDefaults({ fastUnpack: false, ignoreDepScripts: true }))
|
||||
{
|
||||
const output = await loadJsonFile<string[]>('output.json')
|
||||
|
||||
expect(output).toStrictEqual(['preinstall', 'install', 'postinstall'])
|
||||
expect(await exists('test.txt')).toBeTruthy()
|
||||
|
||||
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -103,6 +103,7 @@ export interface HeadlessOptions {
|
||||
extraNodePaths?: string[]
|
||||
preferSymlinkedExecutables?: boolean
|
||||
hoistingLimits?: HoistingLimits
|
||||
ignoreDepScripts: boolean
|
||||
ignoreScripts: boolean
|
||||
ignorePackageManifest?: boolean
|
||||
include: IncludedDependencies
|
||||
@@ -435,7 +436,7 @@ export default async (opts: HeadlessOptions) => {
|
||||
extraBinPaths,
|
||||
extraEnv,
|
||||
depsStateCache,
|
||||
ignoreScripts: opts.ignoreScripts,
|
||||
ignoreScripts: opts.ignoreScripts || opts.ignoreDepScripts,
|
||||
lockfileDir,
|
||||
optional: opts.include.optionalDependencies,
|
||||
preferSymlinkedExecutables: opts.preferSymlinkedExecutables,
|
||||
|
||||
Reference in New Issue
Block a user