Skip to content

Commit 59abbd9

Browse files
test: refactor local skillsbase path resolution
Remove monorepo root assumption and add flexible local skillsbase discovery with null safety. Improves test portability across different repository structures. Co-Authored-By: Hagicode <noreply@hagicode.com> Signed-off-by: newbe36524 <newbe36524@qq.com>
1 parent 652b304 commit 59abbd9

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

tests/template-contract.test.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { promisify } from "node:util";
99

1010
const execFile = promisify(execFileCallback);
1111
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
12-
const monorepoRoot = path.resolve(repoRoot, "..", "..");
1312

1413
function parseScalar(rawValue) {
1514
const value = rawValue.trim();
@@ -68,13 +67,18 @@ async function collectRelativeFiles(rootPath, basePath = rootPath) {
6867
}
6968

7069
async function createFakeGlobalSkillsbase(binRoot) {
70+
const localSkillsbasePath = path.resolve(repoRoot, "..", "skillsbase", "bin", "skillsbase.mjs");
71+
if (!(await pathExists(localSkillsbasePath))) {
72+
return null;
73+
}
74+
7175
const binDir = path.join(binRoot, "bin");
7276
const scriptPath = path.join(binDir, "skillsbase");
7377
await fs.mkdir(binDir, { recursive: true });
7478
await fs.writeFile(
7579
scriptPath,
7680
`#!/usr/bin/env bash
77-
exec node "${path.join(monorepoRoot, "repos", "skillsbase", "bin", "skillsbase.mjs")}" "$@"
81+
exec node "${localSkillsbasePath}" "$@"
7882
`,
7983
"utf8",
8084
);
@@ -229,7 +233,7 @@ test("repo-local drift check stays stable outside the template working directory
229233
cwd: os.tmpdir(),
230234
env: {
231235
...process.env,
232-
PATH: `${fakeBin}:${process.env.PATH}`,
236+
PATH: fakeBin ? `${fakeBin}:${process.env.PATH}` : process.env.PATH,
233237
},
234238
maxBuffer: 16 * 1024 * 1024,
235239
timeout: 60_000,

0 commit comments

Comments
 (0)