import ejs from "ejs" ; import fs from "fs" ; import path from "path" ; import { promisify } from "util" ; const { ASSETS_BASE } = require ( "./consts" ) ; export const readFile = promisify ( fs . readFile ) ; export const readAsset = async ( file , encoding ? ) => exports . readFile ( path . resolve ( ASSETS_BASE , file ) , encoding ) ; export const renderTemplate = async ( name , data ) => new Promise ( ( resolve , reject ) => { const tmplPath = path . resolve ( ASSETS_BASE , "tmpl" , `${ name }.html.ejs` ) ; ejs . renderFile ( tmplPath , data , ( err , res ) => { err ? reject ( err ) : resolve ( res ) ; } ) ; } ) ;