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:
Khải
2025-08-13 05:10:20 +07:00
committed by GitHub
parent ab7a939b51
commit 52624e2b6b
3 changed files with 9 additions and 9 deletions

View File

@@ -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)) {

View File

@@ -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>

View File

@@ -0,0 +1,7 @@
export function settingShouldFallBackToNpm (key: string): boolean {
return (
['registry', '_auth', '_authToken', 'username', '_password'].includes(key) ||
key[0] === '@' ||
key.startsWith('//')
)
}