Skip to content

Commit

Permalink
feat: ignore packages listed in pnpm.update.ignore field on update co…
Browse files Browse the repository at this point in the history
…mmand
  • Loading branch information
Shinyaigeek committed Sep 30, 2022
1 parent 8b97c14 commit a6fddbc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/plugin-commands-installation/src/installDeps.ts
Expand Up @@ -201,6 +201,11 @@ when running add/update with the --workspace option')

let currentInput = [...params]

if (opts.update) {
const ignoredPackages = (manifest.pnpm?.updateConfig?.ignoreDependencies ?? [])
currentInput = [...ignoredPackages.map(pkg => `!${pkg}`), ...currentInput]
}

const updateMatch = opts.update && (currentInput.length > 0) ? createMatcher(currentInput) : null
if (updateMatch != null) {
currentInput = matchDependencies(updateMatch, manifest, includeDirect)
Expand Down
12 changes: 10 additions & 2 deletions packages/plugin-commands-installation/src/recursive.ts
Expand Up @@ -173,8 +173,6 @@ export default async function recursive (
optionalDependencies: true,
}

const updateMatch = cmdFullName === 'update' && (params.length > 0) ? createMatcher(params) : null

// For a workspace with shared lockfile
if (opts.lockfileDir && ['add', 'install', 'remove', 'update', 'import'].includes(cmdFullName)) {
let importers = await getImporters()
Expand All @@ -201,6 +199,11 @@ export default async function recursive (
const modulesDir = localConfig.modulesDir ?? opts.modulesDir
const { manifest, writeProjectManifest } = manifestsByPath[rootDir]
let currentInput = [...params]
if (opts.update) {
const ignoredPackages = (manifest.pnpm?.updateConfig?.ignoreDependencies ?? [])
currentInput = [...ignoredPackages.map(pkg => `!${pkg}`), ...currentInput]
}
const updateMatch = cmdFullName === 'update' && (currentInput.length > 0) ? createMatcher(currentInput) : null
if (updateMatch != null) {
currentInput = matchDependencies(updateMatch, manifest, includeDirect)
if ((currentInput.length === 0) && (typeof opts.depth === 'undefined' || opts.depth <= 0)) {
Expand Down Expand Up @@ -308,6 +311,11 @@ export default async function recursive (

const { manifest, writeProjectManifest } = manifestsByPath[rootDir]
let currentInput = [...params]
if (opts.update) {
const ignoredPackages = (manifest.pnpm?.updateConfig?.ignoreDependencies ?? [])
currentInput = [...ignoredPackages.map(pkg => `!${pkg}`), ...currentInput]
}
const updateMatch = cmdFullName === 'update' && (currentInput.length > 0) ? createMatcher(currentInput) : null
if (updateMatch != null) {
currentInput = matchDependencies(updateMatch, manifest, includeDirect)
if (currentInput.length === 0) return
Expand Down

0 comments on commit a6fddbc

Please sign in to comment.