diff --git a/arkui-plugins/test/localtest_config.js b/arkui-plugins/test/localtest_config.js index 87fd2e7eec4599b2e9449a9913998b7bf3710527..6372cbc8cfcc8b73e14d6ca0387a896aff08a9e6 100644 --- a/arkui-plugins/test/localtest_config.js +++ b/arkui-plugins/test/localtest_config.js @@ -16,6 +16,10 @@ const fs = require('fs'); const path = require('path'); +function changePathToAbsPath(p) { + return path.resolve(p); +} + // 获取当前目录 const currentDirectory = process.cwd(); let workSpace = currentDirectory; @@ -44,6 +48,36 @@ try { jsonData.plugins.memo_plugin = jsonData.plugins.memo_plugin.replace(/workspace/g, workSpace); } + // compileFiles + if (jsonData.compileFiles) { + jsonData.compileFiles = jsonData.compileFiles.map((file) => changePathToAbsPath(file)); + } + + // entryFiles + if (jsonData.entryFiles) { + jsonData.entryFiles = jsonData.entryFiles.map((file) => changePathToAbsPath(file)); + } + + // moduleRootPath + if (jsonData.moduleRootPath) { + jsonData.moduleRootPath = changePathToAbsPath(jsonData.moduleRootPath); + } + + // sourceRoots + if (jsonData.sourceRoots) { + jsonData.sourceRoots = jsonData.sourceRoots.map((file) => changePathToAbsPath(file)); + } + + // loaderOutPath + if (jsonData.loaderOutPath) { + jsonData.loaderOutPath = changePathToAbsPath(jsonData.loaderOutPath); + } + + // loaderOutPath + if (jsonData.cachePath) { + jsonData.cachePath = changePathToAbsPath(jsonData.cachePath); + } + // 将修改后的内容写回 JSON 文件 fs.writeFileSync(outJsonFilePath, JSON.stringify(jsonData, null, 2), 'utf8'); } catch (error) {