mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-15 02:18:31 -05:00
feat: add support for pnpm config get globalconfig (#10090)
close #9977
This commit is contained in:
committed by
Zoltan Kochan
parent
36eb104e99
commit
7b19077fcb
7
.changeset/quick-rice-hang.md
Normal file
7
.changeset/quick-rice-hang.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-config": minor
|
||||
"@pnpm/config": minor
|
||||
"pnpm": minor
|
||||
---
|
||||
|
||||
Added support for `pnpm config get globalconfig` to retrieve the global config file path [#9977](https://github.com/pnpm/pnpm/issues/9977).
|
||||
@@ -201,7 +201,6 @@ export interface Config extends OptionsFromRootManifest {
|
||||
rootProjectManifest?: ProjectManifest
|
||||
userConfig: Record<string, string>
|
||||
|
||||
globalconfig: string
|
||||
hoist: boolean
|
||||
packageLock: boolean
|
||||
pending: boolean
|
||||
|
||||
@@ -157,7 +157,6 @@ export async function getConfig (opts: {
|
||||
'bitbucket.com',
|
||||
'bitbucket.org',
|
||||
],
|
||||
globalconfig: npmDefaults.globalconfig,
|
||||
'git-branch-lockfile': false,
|
||||
hoist: true,
|
||||
'hoist-pattern': ['*'],
|
||||
@@ -267,6 +266,8 @@ export async function getConfig (opts: {
|
||||
...[...npmConfig.list].reverse(),
|
||||
cliOptions,
|
||||
{ 'user-agent': pnpmConfig.userAgent },
|
||||
{ globalconfig: path.join(configDir, 'rc') },
|
||||
{ 'npm-globalconfig': npmDefaults.globalconfig },
|
||||
] as any) // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
const networkConfigs = getNetworkConfigs(pnpmConfig.rawConfig)
|
||||
pnpmConfig.registries = {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as ini from 'ini'
|
||||
import path from 'path'
|
||||
import { config } from '@pnpm/plugin-commands-config'
|
||||
import { getOutputString } from './utils/index.js'
|
||||
|
||||
@@ -219,3 +220,34 @@ test('config get with scoped registry key that does not exist', async () => {
|
||||
|
||||
expect(getOutputString(getResult)).toBe('undefined')
|
||||
})
|
||||
|
||||
test('config get globalconfig', async () => {
|
||||
const configDir = process.cwd()
|
||||
const expectedGlobalconfigPath = path.join(configDir, 'rc')
|
||||
const getResult = await config.handler({
|
||||
dir: process.cwd(),
|
||||
cliOptions: {},
|
||||
configDir,
|
||||
global: true,
|
||||
rawConfig: {
|
||||
globalconfig: expectedGlobalconfigPath,
|
||||
},
|
||||
}, ['get', 'globalconfig'])
|
||||
|
||||
expect(getOutputString(getResult)).toBe(expectedGlobalconfigPath)
|
||||
})
|
||||
|
||||
test('config get npm-globalconfig', async () => {
|
||||
const npmGlobalconfigPath = path.join('/root', '.npmrc')
|
||||
const getResult = await config.handler({
|
||||
dir: process.cwd(),
|
||||
cliOptions: {},
|
||||
configDir: process.cwd(),
|
||||
global: true,
|
||||
rawConfig: {
|
||||
'npm-globalconfig': npmGlobalconfigPath,
|
||||
},
|
||||
}, ['get', 'npm-globalconfig'])
|
||||
|
||||
expect(getOutputString(getResult)).toBe(npmGlobalconfigPath)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user