fix: pnpm cache view command should specify package name (#8582)
This commit is contained in:
6 files changed
+41
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/cache.commands": patch
|
||||
---
|
||||
|
||||
`pnpm cache view` should specify package name
|
||||
Vendored
+1
@@ -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:"
|
||||
|
||||
Vendored
+7
@@ -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
@@ -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')
|
||||
})
|
||||
})
|
||||
Vendored
+3
@@ -21,6 +21,9 @@
|
||||
{
|
||||
"path": "../../packages/constants"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/error"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/logger"
|
||||
},
|
||||
|
||||
Generated
+3
@@ -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