diff --git a/lib/workers/global/config/parse/file.spec.ts b/lib/workers/global/config/parse/file.spec.ts index a07f0aa2a711c8386fe27f11652bbd2f35f47eec..f4827e6ad6fa6576fe5404052ef3d772c3229a93 100644 --- a/lib/workers/global/config/parse/file.spec.ts +++ b/lib/workers/global/config/parse/file.spec.ts @@ -50,7 +50,9 @@ describe('workers/global/config/parse/file', () => { it('migrates', async () => { const configFile = upath.resolve(__dirname, './__fixtures__/config2.js'); - const res = await file.getConfig({ RENOVATE_CONFIG_FILE: configFile }); + // for coverage + const relativePath = upath.relative(process.cwd(), configFile); + const res = await file.getConfig({ RENOVATE_CONFIG_FILE: relativePath }); expect(res).toMatchSnapshot(); expect(res.rangeStrategy).toBe('bump'); }); diff --git a/lib/workers/global/config/parse/file.ts b/lib/workers/global/config/parse/file.ts index 8e8d8bb5a3db3de483aa9d2df27c2c33764ec305..655503f749ca7f4bde2f09416705f88c26fd2960 100644 --- a/lib/workers/global/config/parse/file.ts +++ b/lib/workers/global/config/parse/file.ts @@ -1,3 +1,4 @@ +import { pathToFileURL } from 'url'; import is from '@sindresorhus/is'; import fs from 'fs-extra'; import JSON5 from 'json5'; @@ -26,9 +27,12 @@ export async function getParsedContent(file: string): Promise<RenovateConfig> { case '.cjs': case '.mjs': case '.js': { - const tmpConfig = await import( - upath.isAbsolute(file) ? file : `${process.cwd()}/${file}` - ); + const absoluteFilePath = upath.isAbsolute(file) + ? file + : `${process.cwd()}/${file}`; + // use file url paths to avoid issues with windows paths + // typescript does not support file URL for import + const tmpConfig = await import(pathToFileURL(absoluteFilePath).href); /* v8 ignore next: not testable */ let config = tmpConfig.default ? tmpConfig.default : tmpConfig; // Allow the config to be a function