diff --git a/src/formatter/builder.ts b/src/formatter/builder.ts index 0800424920..c75d0cb873 100644 --- a/src/formatter/builder.ts +++ b/src/formatter/builder.ts @@ -103,8 +103,15 @@ const FormatterBuilder = { }, loadCustomFormatter(customFormatterPath: string, cwd: string) { - const fullCustomFormatterPath = path.resolve(cwd, customFormatterPath) - const CustomFormatter = require(fullCustomFormatterPath) // eslint-disable-line @typescript-eslint/no-var-requires + let CustomFormatter = null + + try { + const fullCustomFormatterPath = path.resolve(cwd, customFormatterPath) + CustomFormatter = require(fullCustomFormatterPath) // eslint-disable-line @typescript-eslint/no-var-requires + } catch { + CustomFormatter = require(customFormatterPath) // eslint-disable-line @typescript-eslint/no-var-requires + } + if (typeof CustomFormatter === 'function') { return CustomFormatter } else if (