mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-11 10:40:53 -04:00
fix: pnpm cache view command should specify package name (#8582)
This commit is contained in:
5
.changeset/tricky-games-give.md
Normal file
5
.changeset/tricky-games-give.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/cache.commands": patch
|
||||
---
|
||||
|
||||
`pnpm cache view` should specify package name
|
||||
1
cache/commands/package.json
vendored
1
cache/commands/package.json
vendored
@@ -43,6 +43,7 @@
|
||||
"@pnpm/cli-utils": "workspace:*",
|
||||
"@pnpm/config": "workspace:*",
|
||||
"@pnpm/constants": "workspace:*",
|
||||
"@pnpm/error": "workspace:*",
|
||||
"@pnpm/store-path": "workspace:*",
|
||||
"ramda": "catalog:",
|
||||
"render-help": "catalog:"
|
||||
|
||||
7
cache/commands/src/cache.cmd.ts
vendored
7
cache/commands/src/cache.cmd.ts
vendored
@@ -11,6 +11,7 @@ import {
|
||||
cacheDelete,
|
||||
cacheListRegistries,
|
||||
} from '@pnpm/cache.api'
|
||||
import { PnpmError } from '@pnpm/error'
|
||||
|
||||
export const rcOptionsTypes = cliOptionsTypes
|
||||
|
||||
@@ -81,6 +82,12 @@ export async function handler (opts: CacheCommandOptions, params: string[]): Pro
|
||||
registry: opts.cliOptions['registry'],
|
||||
}, params.slice(1))
|
||||
case 'view': {
|
||||
if (!params[1]) {
|
||||
throw new PnpmError('MISSING_PACKAGE_NAME', '`pnpm cache view` requires the package name')
|
||||
}
|
||||
if (params.length > 2) {
|
||||
throw new PnpmError('TOO_MANY_PARAMS', '`pnpm cache view` only accepts one package name')
|
||||
}
|
||||
const storeDir = await getStorePath({
|
||||
pkgRoot: process.cwd(),
|
||||
storePath: opts.storeDir,
|
||||
|
||||
22
cache/commands/test/cacheView.cmd.test.ts
vendored
22
cache/commands/test/cacheView.cmd.test.ts
vendored
@@ -90,4 +90,26 @@ describe('cache view', () => {
|
||||
}),
|
||||
}))
|
||||
})
|
||||
|
||||
test('lists all metadata for requested package should specify a package name', async () => {
|
||||
await expect(
|
||||
cache.handler({
|
||||
cacheDir,
|
||||
cliOptions: {},
|
||||
pnpmHomeDir: process.cwd(),
|
||||
storeDir,
|
||||
}, ['view'])
|
||||
).rejects.toThrow('`pnpm cache view` requires the package name')
|
||||
})
|
||||
|
||||
test('lists all metadata for requested package should not accept more than one package name', async () => {
|
||||
await expect(
|
||||
cache.handler({
|
||||
cacheDir,
|
||||
cliOptions: {},
|
||||
pnpmHomeDir: process.cwd(),
|
||||
storeDir,
|
||||
}, ['view', 'is-negative', 'is-positive'])
|
||||
).rejects.toThrow('`pnpm cache view` only accepts one package name')
|
||||
})
|
||||
})
|
||||
|
||||
3
cache/commands/tsconfig.json
vendored
3
cache/commands/tsconfig.json
vendored
@@ -21,6 +21,9 @@
|
||||
{
|
||||
"path": "../../packages/constants"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/error"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/logger"
|
||||
},
|
||||
|
||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -1080,6 +1080,9 @@ importers:
|
||||
'@pnpm/constants':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/constants
|
||||
'@pnpm/error':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/error
|
||||
'@pnpm/store-path':
|
||||
specifier: workspace:*
|
||||
version: link:../../store/store-path
|
||||
|
||||
Reference in New Issue
Block a user