fix: make npm test and typecheck runnable / 修正 npm test 與 typecheck 可直接執行

This commit is contained in:
Alice (OpenClaw)
2026-05-14 10:49:08 +08:00
parent 25a351321e
commit 64dae38e9c
4 changed files with 25 additions and 3 deletions

View File

@@ -9,8 +9,8 @@
"refresh:openclawtest": "bash ./scripts/refresh-openclawtest-poc.sh",
"rollback:openclawtest": "bash ./scripts/rollback-openclaw-poc-patch.sh /home/openclawtest/.nvm/versions/node/v22.22.2/lib/node_modules/openclaw/dist",
"verify:openclawtest": "bash ./scripts/verify-openclaw-poc.sh /home/openclawtest/.openclaw /home/openclawtest/.nvm/versions/node/v22.22.2/lib/node_modules/openclaw/dist",
"test": "tsx --test tests/**/*.test.mjs",
"typecheck": "tsc --noEmit"
"test": "npx -p tsx@4.20.6 -p typescript@5.9.3 tsx --test tests/**/*.test.mjs",
"typecheck": "npx -p typescript@5.9.3 tsc --noEmit"
},
"devDependencies": {
"tsx": "^4.20.6",

View File

@@ -1,5 +1,17 @@
import type { ReplyEndChoice } from "./types.js"
import config from "../config/reply-end-controls.json"
import fs from "node:fs"
import path from "node:path"
import { fileURLToPath } from "node:url"
const currentDir = path.dirname(fileURLToPath(import.meta.url))
const configPath = path.join(currentDir, "..", "config", "reply-end-controls.json")
const config = JSON.parse(fs.readFileSync(configPath, "utf-8")) as {
callbacks: Record<ReplyEndChoice, string>
labels: Record<ReplyEndChoice, string>
resolvedLabels: Record<ReplyEndChoice, string>
ack: Record<ReplyEndChoice, string>
stopPolicyText: string
}
export const REPLY_END_CALLBACKS = config.callbacks as Record<ReplyEndChoice, string>

8
src/node-shims.d.ts vendored
View File

@@ -7,3 +7,11 @@ declare module "node:path" {
const path: any
export default path
}
declare module "node:url" {
export function fileURLToPath(url: string | URL): string
}
interface ImportMeta {
url: string
}

View File

@@ -4,6 +4,8 @@
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"noEmit": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,