mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-15 03:56:15 -04:00
18 lines
681 B
TypeScript
18 lines
681 B
TypeScript
import { type DependencyManifest } from '@pnpm/types'
|
|
|
|
export function pkgRequiresBuild (manifest: Partial<DependencyManifest> | undefined, filesIndex: Record<string, unknown>): boolean {
|
|
return Boolean(
|
|
manifest?.scripts != null && (
|
|
Boolean(manifest.scripts.preinstall) ||
|
|
Boolean(manifest.scripts.install) ||
|
|
Boolean(manifest.scripts.postinstall)
|
|
) ||
|
|
filesIncludeInstallScripts(filesIndex)
|
|
)
|
|
}
|
|
|
|
function filesIncludeInstallScripts (filesIndex: Record<string, unknown>): boolean {
|
|
return filesIndex['binding.gyp'] != null ||
|
|
Object.keys(filesIndex).some((filename) => !(filename.match(/^[.]hooks[\\/]/) == null)) // TODO: optimize this
|
|
}
|