fix(cli): fix misuse of configPath as readNapiConfig first argument (#2900)

Co-authored-by: LongYinan <lynweklm@gmail.com>
This commit is contained in:
Kingsword 2025-09-04 16:12:31 +08:00 committed by GitHub
parent df80a8447a
commit c034e1e4f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 10 deletions

View File

@ -1,4 +1,4 @@
import { join, parse } from 'node:path'
import { join, resolve, parse } from 'node:path'
import * as colors from 'colorette'
@ -20,9 +20,12 @@ const debug = debugFactory('artifacts')
export async function collectArtifacts(userOptions: ArtifactsOptions) {
const options = applyDefaultArtifactsOptions(userOptions)
const packageJsonPath = join(options.cwd, options.packageJsonPath)
const { targets, binaryName, packageName } =
await readNapiConfig(packageJsonPath)
const resolvePath = (...paths: string[]) => resolve(options.cwd, ...paths)
const packageJsonPath = resolvePath(options.packageJsonPath)
const { targets, binaryName, packageName } = await readNapiConfig(
packageJsonPath,
options.configPath ? resolvePath(options.configPath) : undefined,
)
const distDirs = targets.map((platform) =>
join(options.cwd, options.npmDir, platform.platformArchABI),

View File

@ -82,9 +82,7 @@ export async function buildProject(rawOptions: BuildOptions) {
)
}
const config = await readNapiConfig(
resolvePath(
options.configPath ?? options.packageJsonPath ?? 'package.json',
),
resolvePath(options.packageJsonPath ?? 'package.json'),
options.configPath ? resolvePath(options.configPath) : undefined,
)

View File

@ -11,9 +11,7 @@ interface MinimalNapiOptions {
export async function readConfig(options: MinimalNapiOptions) {
const resolvePath = (...paths: string[]) => resolve(options.cwd, ...paths)
const config = await readNapiConfig(
resolvePath(
options.configPath ?? options.packageJsonPath ?? 'package.json',
),
resolvePath(options.packageJsonPath ?? 'package.json'),
options.configPath ? resolvePath(options.configPath) : undefined,
)
return config