From 1391570e44c970a97738b84f5279480ca117b037 Mon Sep 17 00:00:00 2001
From: Sigurd Spieckermann <2206639+sisp@users.noreply.github.com>
Date: Tue, 13 Feb 2024 17:51:20 +0100
Subject: [PATCH] fix(validator): use absolute path for all `.js` configs
 (#27139)

---
 lib/workers/global/config/parse/file.ts | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/workers/global/config/parse/file.ts b/lib/workers/global/config/parse/file.ts
index 14c13c06a8..ac56ec629a 100644
--- a/lib/workers/global/config/parse/file.ts
+++ b/lib/workers/global/config/parse/file.ts
@@ -27,7 +27,9 @@ export async function getParsedContent(file: string): Promise<RenovateConfig> {
       ) as RenovateConfig;
     case '.cjs':
     case '.js': {
-      const tmpConfig = await import(file);
+      const tmpConfig = await import(
+        upath.isAbsolute(file) ? file : `${process.cwd()}/${file}`
+      );
       let config = tmpConfig.default
         ? tmpConfig.default
         : /* istanbul ignore next: hard to test */ tmpConfig;
@@ -43,10 +45,7 @@ export async function getParsedContent(file: string): Promise<RenovateConfig> {
 }
 
 export async function getConfig(env: NodeJS.ProcessEnv): Promise<AllConfig> {
-  let configFile = env.RENOVATE_CONFIG_FILE ?? 'config.js';
-  if (!upath.isAbsolute(configFile)) {
-    configFile = `${process.cwd()}/${configFile}`;
-  }
+  const configFile = env.RENOVATE_CONFIG_FILE ?? 'config.js';
 
   if (env.RENOVATE_CONFIG_FILE && !(await fs.pathExists(configFile))) {
     logger.fatal(
-- 
GitLab