import { promises as fs } from 'fs' ; export const { readFile , writeFile } = fs ; export function getInterpolationRegExp ( string ? ) { if ( typeof string === 'string' ) return new RegExp ( `<%= ${ string } %>` , 'g' ) ; else return /<%= (\w+) =%>/g ; } export function processTemplate ( template , interpolations ) { let partial = template ; Object . entries ( interpolations ) . forEach ( ( [ key , value ] ) => { partial = partial . replace ( getInterpolationRegExp ( key ) , value || '' ) ; } ) ; return partial . replace ( getInterpolationRegExp ( ) , '' ) ; }