mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-06 15:07:27 -04:00
fix: non-recursive install ignores filter from config
This commit is contained in:
@@ -177,13 +177,15 @@ export default async function run (argv: string[]) {
|
||||
})
|
||||
}
|
||||
|
||||
if (
|
||||
const dashDashFilterUsed = (
|
||||
(
|
||||
cmd === 'recursive' && !COMMANDS_WITH_NO_DASHDASH_FILTER.has(subCmd) ||
|
||||
cmd !== 'recursive' && !COMMANDS_WITH_NO_DASHDASH_FILTER.has(cmd)
|
||||
) &&
|
||||
cliConf.argv.cooked.indexOf('--') !== -1
|
||||
) {
|
||||
cmd === 'recursive' && !COMMANDS_WITH_NO_DASHDASH_FILTER.has(subCmd)
|
||||
|| cmd !== 'recursive' && !COMMANDS_WITH_NO_DASHDASH_FILTER.has(cmd)
|
||||
)
|
||||
&& cliConf.argv.cooked.indexOf('--') !== -1
|
||||
)
|
||||
|
||||
if (dashDashFilterUsed) {
|
||||
opts.filter = opts.filter || []
|
||||
const dashDashIndex = cliConf.argv.cooked.indexOf('--')
|
||||
Array.prototype.push.apply(opts.filter, cliConf.argv.cooked.slice(dashDashIndex + 1))
|
||||
@@ -194,7 +196,7 @@ export default async function run (argv: string[]) {
|
||||
// `pnpm install ""` is going to be just `pnpm install`
|
||||
const cliArgs = cliConf.argv.remain.slice(1).filter(Boolean)
|
||||
|
||||
if (opts.filter && opts.filter.length && cmd !== 'recursive') {
|
||||
if (cmd !== 'recursive' && (dashDashFilterUsed || argv.indexOf('--filter') !== -1)) {
|
||||
subCmd = cmd
|
||||
cmd = 'recursive'
|
||||
cliArgs.unshift(subCmd)
|
||||
|
||||
@@ -993,6 +993,45 @@ test('recursive command with filter from config', async (t: tape.Test) => {
|
||||
projects['project-3'].hasNot('minimatch')
|
||||
})
|
||||
|
||||
test('non-recursive install ignores filter from config', async (t: tape.Test) => {
|
||||
const projects = preparePackages(t, [
|
||||
{
|
||||
location: '.',
|
||||
package: {
|
||||
name: 'project-1',
|
||||
version: '1.0.0',
|
||||
|
||||
dependencies: {
|
||||
'is-positive': '1.0.0',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'project-2',
|
||||
version: '1.0.0',
|
||||
|
||||
dependencies: {
|
||||
'is-negative': '1.0.0',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'project-3',
|
||||
version: '1.0.0',
|
||||
|
||||
dependencies: {
|
||||
minimatch: '*',
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
await fs.writeFile('.npmrc', 'filter=project-2', 'utf8')
|
||||
await execPnpm('install')
|
||||
|
||||
projects['project-1'].has('is-positive')
|
||||
projects['project-2'].hasNot('is-negative')
|
||||
projects['project-3'].hasNot('minimatch')
|
||||
})
|
||||
|
||||
test('recursive install --no-bail', async (t: tape.Test) => {
|
||||
const projects = preparePackages(t, [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user