import readPackageJson , { ScriptsObject } from "read-package-json-fast" ; let scripts ; export function clearCachedScripts ( ) { scripts = undefined ; } async function readPackageJsonScripts ( jsonPath ) { const packageJson = await readPackageJson ( `${ jsonPath }` ) ; return packageJson . scripts || { } ; } param scriptName export async function getPackageJsonScript ( scriptName ) { if ( ! scriptName ) { return undefined ; } if ( process . env . npm_package_json ) { if ( ! scripts ) { scripts = await readPackageJsonScripts ( process . env . npm_package_json ) ; } return scripts [ scriptName ] ; } return process . env [ `npm_package_scripts_${ scriptName . replace ( /-/g , "_" ) }` ] ; }