@@ -14,18 +14,18 @@ const debug = debugFactory('babel-plugin-tester:formatter');
1414type MaybePrettierOptions = PrettierOptions | null ;
1515const configDirectoryCache : Record < string , MaybePrettierOptions > = Object . create ( null ) ;
1616
17- const getCachedConfig = ( directory : string ) => {
18- if ( ! ( directory in configDirectoryCache ) ) {
17+ const getCachedConfig = ( filepath : string ) => {
18+ if ( ! ( filepath in configDirectoryCache ) ) {
19+ configDirectoryCache [ filepath ] = resolvePrettierConfig . sync ( filepath ) ;
1920 debug (
20- `caching prettier configuration resolved from ${ directory } : %O` ,
21- configDirectoryCache [ directory ]
21+ `caching prettier configuration resolved from ${ filepath } : %O` ,
22+ configDirectoryCache [ filepath ]
2223 ) ;
23- configDirectoryCache [ directory ] = resolvePrettierConfig . sync ( directory ) ;
2424 } else {
25- debug ( `using cached prettier configuration resolved from ${ directory } ` ) ;
25+ debug ( `using cached prettier configuration resolved from ${ filepath } ` ) ;
2626 }
2727
28- return configDirectoryCache [ directory ] ;
28+ return configDirectoryCache [ filepath ] ;
2929} ;
3030
3131export type { PrettierOptions } ;
@@ -58,7 +58,7 @@ export const prettierFormatter: ResultFormatter<{
5858 filename,
5959 filepath = filename || path . join ( cwd , 'dummy.js' ) ,
6060 config,
61- prettierOptions = config || getCachedConfig ( cwd )
61+ prettierOptions = config || getCachedConfig ( filepath )
6262 } = { }
6363) => {
6464 const finalPrettierOptions = {
0 commit comments