Skip to content

Commit

Permalink
Upgrade prettier.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Mar 12, 2024
1 parent 902924c commit 7efd7b5
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 68 deletions.
7 changes: 3 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const uncode = (s: string) => s.replace(/`/g, '')
notifier.update.type === 'major'
? chalk.red('{latestVersion}')
: notifier.update.type === 'minor'
? chalk.yellow('{latestVersion}')
: chalk.green('{latestVersion}')
? chalk.yellow('{latestVersion}')
: chalk.green('{latestVersion}')
}
Run ${chalk.cyan('{updateCommand}')} to update
${chalk.dim.underline(
Expand Down Expand Up @@ -108,14 +108,14 @@ ${chalk.dim.underline(
option.long && noCli.has(option.long)
? option.long.replace('--', '') + '*'
: option.long === '--version'
? '-v, -V, --version'
: option.flags.replace('[bool]', ''),
? '-v, -V, --version'
: option.flags.replace('[bool]', ''),
optionDescription: option =>
option.long === '--version'
? 'Output the version number of npm-check-updates.'
: option.long === '--help'
? `You're lookin' at it.`
: Help.prototype.optionDescription(option),
? `You're lookin' at it.`
: Help.prototype.optionDescription(option),
})

// add cli options
Expand Down
8 changes: 4 additions & 4 deletions src/lib/getNcuRc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ async function getNcuRc({ color, configFileName, configFilePath, packageFile, gl
value === true || (cliOptionsMap[name]?.type === 'boolean' && value)
? [`--${name}`]
: // if a boolean option is false, exclude it
value === false || (cliOptionsMap[name]?.type === 'boolean' && !value)
? []
: // otherwise render as a 2-tuple
[`--${name}`, value],
value === false || (cliOptionsMap[name]?.type === 'boolean' && !value)
? []
: // otherwise render as a 2-tuple
[`--${name}`, value],
),
)
: []
Expand Down
4 changes: 2 additions & 2 deletions src/lib/getRepoUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ async function getRepoUrl(
const repositoryMetadata: string | PackageFileRepository | null = !packageJson
? await getPackageRepo(packageName, { pkgFile })
: packageJson.repository
? packageJson.repository
: null
? packageJson.repository
: null

if (!repositoryMetadata) return null

Expand Down
12 changes: 6 additions & 6 deletions src/lib/libnpmconfig/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ function getNpmConfig(_opts, _builtin) {
cli.cache || env.cache
? builtin.cwd
: proj.cache
? path.dirname(projConfPath)
: user.cache
? path.dirname(userConfPath)
: global.cache
? path.dirname(globalConfPath)
: path.dirname(userConfPath),
? path.dirname(projConfPath)
: user.cache
? path.dirname(userConfPath)
: global.cache
? path.dirname(globalConfPath)
: path.dirname(userConfPath),
newOpts.cache,
),
})
Expand Down
8 changes: 4 additions & 4 deletions src/lib/runGlobal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ async function runGlobal(options: Options): Promise<Index<string> | void> {
options.packageManager === 'yarn'
? 'yarn global upgrade'
: options.packageManager === 'pnpm'
? 'pnpm -g add'
: options.packageManager === 'bun'
? 'bun add -g'
: 'npm -g install'
? 'pnpm -g add'
: options.packageManager === 'bun'
? 'bun add -g'
: 'npm -g install'

print(
options,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/runLocal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ async function runLocal(
const output = options.jsonAll
? (jph.parse(newPkgData) as PackageFile)
: options.jsonDeps
? pick(jph.parse(newPkgData) as PackageFile, resolveDepSections(options.dep))
: chosenUpgraded
? pick(jph.parse(newPkgData) as PackageFile, resolveDepSections(options.dep))
: chosenUpgraded

// will be overwritten with the result of fs.writeFile so that the return promise waits for the package file to be written
let writePromise = Promise.resolve()
Expand Down
4 changes: 2 additions & 2 deletions src/lib/upgradeDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ function upgradeDependencies(
return versionUtil.isNpmAlias(current)
? versionUtil.upgradeNpmAlias(current, upgraded)
: versionUtil.isGithubUrl(current)
? versionUtil.upgradeGithubUrl(current, upgraded)
: upgraded
? versionUtil.upgradeGithubUrl(current, upgraded)
: upgraded
}),
])(currentDependencies)
}
Expand Down
12 changes: 6 additions & 6 deletions src/lib/version-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export function precisionAdd(precision: VersionPart, n: number) {
const index = VERSION_BASE_PARTS.includes(precision)
? VERSION_BASE_PARTS.indexOf(precision) + n
: VERSION_ADDED_PARTS.includes(precision)
? VERSION_BASE_PARTS.length + n
: null
? VERSION_BASE_PARTS.length + n
: null

if (index === null || !VERSION_PARTS[index]) {
throw new Error(`Invalid precision: ${precision}`)
Expand Down Expand Up @@ -491,10 +491,10 @@ export function upgradeDependencyDeclaration(
(isWildPart(declaredSemver[part])
? declaredSemver[part]
: VERSION_BASE_PARTS.includes(part) && declaredSemver[part]
? latestSemver[part]
: VERSION_ADDED_PARTS.includes(part)
? latestSemver[part]
: null) || null
? latestSemver[part]
: VERSION_ADDED_PARTS.includes(part)
? latestSemver[part]
: null) || null
)
}

Expand Down
52 changes: 26 additions & 26 deletions src/package-managers/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ export const normalizeNpmConfig = (
typeof value !== 'string'
? value
: // parse stringified booleans
keyTypes[key.replace(/-/g, '').toLowerCase()] === 'boolean'
? stringToBoolean(value)
: keyTypes[key.replace(/-/g, '').toLowerCase()] === 'number'
? stringToNumber(value)
: value.replace(/\${([^}]+)}/, (_, envVar) => process.env[envVar] as string)
keyTypes[key.replace(/-/g, '').toLowerCase()] === 'boolean'
? stringToBoolean(value)
: keyTypes[key.replace(/-/g, '').toLowerCase()] === 'number'
? stringToNumber(value)
: value.replace(/\${([^}]+)}/, (_, envVar) => process.env[envVar] as string)

// normalize the key for pacote
const { [key]: pacoteKey }: Index<NpmConfig[keyof NpmConfig]> = npmConfigToPacoteMap
Expand All @@ -171,10 +171,10 @@ export const normalizeNpmConfig = (
? // key is mapped to a string
{ [pacoteKey]: normalizedValue }
: // key is mapped to a function
typeof pacoteKey === 'function'
? { ...(pacoteKey(normalizedValue.toString()) as any) }
: // otherwise assign the camel-cased key
{ [key.match(/^[a-z]/i) ? camelCase(key) : key]: normalizedValue }
typeof pacoteKey === 'function'
? { ...(pacoteKey(normalizedValue.toString()) as any) }
: // otherwise assign the camel-cased key
{ [key.match(/^[a-z]/i) ? camelCase(key) : key]: normalizedValue }
})

return config
Expand Down Expand Up @@ -282,8 +282,8 @@ export const mockViewMany =
typeof mockReturnedVersions === 'function'
? mockReturnedVersions(options)?.[name]
: typeof mockReturnedVersions === 'string' || isPackument(mockReturnedVersions)
? mockReturnedVersions
: mockReturnedVersions[name]
? mockReturnedVersions
: mockReturnedVersions[name]

const version = isPackument(partialPackument) ? partialPackument.version : partialPackument

Expand Down Expand Up @@ -317,15 +317,15 @@ export const mockViewMany =
[version]: packument,
} as Index<Packument>)
: field === 'time'
? ({
[version]: time,
} as Index<string>)
: ({
...packument,
versions: {
[version]: packument,
},
} as Packument),
? ({
[version]: time,
} as Index<string>)
: ({
...packument,
versions: {
[version]: packument,
},
} as Packument),
})),
)
}
Expand Down Expand Up @@ -583,12 +583,12 @@ export async function defaultPrefix(options: Options): Promise<string | undefine
return options.global && prefix?.match('Cellar')
? '/usr/local'
: // Workaround: get prefix on windows for global packages
// Only needed when using npm api directly
process.platform === 'win32' && options.global && !process.env.prefix
? prefix
? prefix.trim()
: `${process.env.AppData}\\npm`
: undefined
// Only needed when using npm api directly
process.platform === 'win32' && options.global && !process.env.prefix
? prefix
? prefix.trim()
: `${process.env.AppData}\\npm`
: undefined
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/package-managers/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@ export async function defaultPrefix(options: Options): Promise<string> {
return options.global && prefix && prefix.match('Cellar')
? '/usr/local'
: // Workaround: get prefix on windows for global packages
// Only needed when using npm api directly
process.platform === 'win32' && options.global && !process.env.prefix
? prefix
? prefix.trim()
: `${process.env.LOCALAPPDATA}\\Yarn\\Data\\global`
: null
// Only needed when using npm api directly
process.platform === 'win32' && options.global && !process.env.prefix
? prefix
? prefix.trim()
: `${process.env.LOCALAPPDATA}\\Yarn\\Data\\global`
: null
}

/**
Expand Down

0 comments on commit 7efd7b5

Please sign in to comment.