import { SystemRequirement , SystemRequirementResolution } from "./models" ; import { validateVersionRequirement } from "./version" ; param requirement returns export const getExecutablePath = ( requirement ) : string | undefined => requirement . environmentVariable && process . env [ requirement . environmentVariable ] ; export type KnownRequirementHandler = ( requirement : SystemRequirement ) => Promise < SystemRequirementResolution | SystemRequirementResolution > ; param name param getVersion name export const defineKnownRequirement = ( name , getVersion ) : KnownRequirementHandler => { return async ( requirement ) => { const executablePath = getExecutablePath ( requirement ) ; const command = executablePath ?? name ; const actualVersion = await getVersion ( command ) ; if ( actualVersion === undefined ) { return { error : true , name , command , message : `'${ name }' command line is not found in the path. Make sure to have ${ name } installed.` , } ; } return validateVersionRequirement ( { name , command } , actualVersion , requirement ) ; } ; } ;