2020-09-04 17:22:15 +09:00
|
|
|
import { join } from 'path'
|
|
|
|
|
|
|
|
export function getNapiConfig(packageJson = 'package.json') {
|
|
|
|
const packageJsonPath = join(process.cwd(), packageJson)
|
|
|
|
|
|
|
|
const pkgJson = require(packageJsonPath)
|
|
|
|
const { version: packageVersion, os, napi, name } = pkgJson
|
|
|
|
const muslPlatforms: string[] = (napi?.musl ?? []).map(
|
|
|
|
(platform: string) => `${platform}-musl`,
|
|
|
|
)
|
|
|
|
const platforms = os
|
2020-09-13 23:06:10 +09:00
|
|
|
const releaseVersion = process.env.RELEASE_VERSION
|
|
|
|
const releaseVersionWithoutPrefix = releaseVersion?.startsWith('v')
|
|
|
|
? releaseVersion.substr(1)
|
|
|
|
: releaseVersion
|
|
|
|
const version = releaseVersionWithoutPrefix ?? packageVersion
|
2020-09-04 17:22:15 +09:00
|
|
|
const packageName = name
|
|
|
|
|
|
|
|
const binaryName = napi?.name ?? 'index'
|
|
|
|
|
|
|
|
return {
|
|
|
|
muslPlatforms,
|
|
|
|
platforms,
|
|
|
|
version,
|
|
|
|
packageName,
|
|
|
|
binaryName,
|
|
|
|
packageJsonPath,
|
|
|
|
content: pkgJson,
|
|
|
|
}
|
|
|
|
}
|