import { Identifiers } from "@ovyerus/licenses" ; import identifiers from "@ovyerus/licenses/simple" ; import fs from "fs" ; export function getLicense ( license , replacements = { } ) { if ( ! identifiers . has ( license as Identifiers [ number ] ) ) throw new TypeError ( "license is not a valid SPDX identifier" ) ; let modified = JSON . parse ( fs . readFileSync ( require . resolve ( `@ovyerus/licenses/licenses/${ license }` ) , "utf-8" ) ) . licenseText ; for ( const [ key , value ] of Object . entries ( replacements ) . filter ( ( [ , value ] ) => value ) ) modified = modified . replace ( new RegExp ( `<${ key }>` , "g" ) , value ) ; return modified ; } export default getLicense ;