import * as path from "path" ; import * as prettier from "prettier" ; export function formatWithPrettier ( filename , sourceText ) { let rootPath = __dirname . replace ( /\\/g , "/" ) ; rootPath = rootPath . substr ( 0 , rootPath . lastIndexOf ( "/packages/" ) ) ; const prettierOptions = { ... require ( path . join ( rootPath , ".prettierrc" ) ) , filepath : filename } ; return prettier . format ( sourceText , prettierOptions ) ; }