mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-29 04:21:39 -04:00
refactor: extract a function into its own file (#9848)
* refactor: extract a function into its own file * style: remove leading empty line * fix: eslint
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import kebabCase from 'lodash.kebabcase'
|
||||
import { runNpm } from '@pnpm/run-npm'
|
||||
import { type ConfigCommandOptions } from './ConfigCommandOptions'
|
||||
import { settingShouldFallBackToNpm } from './configSet'
|
||||
import { settingShouldFallBackToNpm } from './settingShouldFallBackToNpm'
|
||||
|
||||
export function configGet (opts: ConfigCommandOptions, key: string): { output: string, exitCode: number } {
|
||||
if (opts.global && settingShouldFallBackToNpm(key)) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import kebabCase from 'lodash.kebabcase'
|
||||
import { readIniFile } from 'read-ini-file'
|
||||
import { writeIniFile } from 'write-ini-file'
|
||||
import { type ConfigCommandOptions } from './ConfigCommandOptions'
|
||||
import { settingShouldFallBackToNpm } from './settingShouldFallBackToNpm'
|
||||
|
||||
export async function configSet (opts: ConfigCommandOptions, key: string, value: string | null): Promise<void> {
|
||||
if (opts.global && settingShouldFallBackToNpm(key)) {
|
||||
@@ -72,14 +73,6 @@ function castField (value: unknown, key: string) {
|
||||
return value
|
||||
}
|
||||
|
||||
export function settingShouldFallBackToNpm (key: string): boolean {
|
||||
return (
|
||||
['registry', '_auth', '_authToken', 'username', '_password'].includes(key) ||
|
||||
key[0] === '@' ||
|
||||
key.startsWith('//')
|
||||
)
|
||||
}
|
||||
|
||||
async function safeReadIniFile (configPath: string): Promise<Record<string, unknown>> {
|
||||
try {
|
||||
return await readIniFile(configPath) as Record<string, unknown>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export function settingShouldFallBackToNpm (key: string): boolean {
|
||||
return (
|
||||
['registry', '_auth', '_authToken', 'username', '_password'].includes(key) ||
|
||||
key[0] === '@' ||
|
||||
key.startsWith('//')
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user