fix(ci): run cross-os checks on Windows

This commit is contained in:
Vincent Koc
2026-05-03 18:05:32 -07:00
parent 0362f64eac
commit c1db7df2ea
3 changed files with 36 additions and 5 deletions

View File

@@ -15,6 +15,19 @@ if ! command -v node >/dev/null 2>&1 || ! command -v npm >/dev/null 2>&1; then
fi
fi
node_cmd="node"
npm_cmd="npm"
if command -v cygpath >/dev/null 2>&1; then
if command -v node.exe >/dev/null 2>&1; then
node_cmd="node.exe"
fi
if command -v npm.cmd >/dev/null 2>&1; then
npm_cmd="npm.cmd"
elif command -v npm.exe >/dev/null 2>&1; then
npm_cmd="npm.exe"
fi
fi
temp_root="${OPENCLAW_RELEASE_TSX_TOOL_ROOT:-${RUNNER_TEMP:-${TMPDIR:-/tmp}}}"
if command -v cygpath >/dev/null 2>&1; then
temp_root="$(cygpath -u "${temp_root}")"
@@ -22,27 +35,34 @@ fi
tool_dir="${OPENCLAW_RELEASE_TSX_TOOL_DIR:-${temp_root}/openclaw-release-tsx-${tsx_version}}"
loader_path="${tool_dir}/node_modules/tsx/dist/loader.mjs"
npm_tool_dir="${tool_dir}"
if command -v cygpath >/dev/null 2>&1; then
npm_tool_dir="$(cygpath -w "${tool_dir}")"
fi
command -v node >/dev/null 2>&1 || {
command -v "${node_cmd}" >/dev/null 2>&1 || {
echo "node is required to run cross-OS release checks." >&2
exit 127
}
command -v npm >/dev/null 2>&1 || {
command -v "${npm_cmd}" >/dev/null 2>&1 || {
echo "npm is required to install the cross-OS release-check loader." >&2
exit 127
}
if [[ ! -f "${loader_path}" ]]; then
mkdir -p "${tool_dir}"
npm install --prefix "${tool_dir}" --no-save --no-package-lock "tsx@${tsx_version}" >/dev/null
if ! "${npm_cmd}" install --prefix "${npm_tool_dir}" --no-save --no-package-lock "tsx@${tsx_version}" >/dev/null; then
echo "failed to install cross-OS release-check loader with ${npm_cmd}." >&2
exit 127
fi
fi
loader_url="$(
node -e '
"${node_cmd}" -e '
const { resolve } = require("node:path");
const { pathToFileURL } = require("node:url");
process.stdout.write(pathToFileURL(resolve(process.argv[1])).href);
' "${loader_path}"
)"
exec node --import "${loader_url}" "${script_path}" "$@"
exec "${node_cmd}" --import "${loader_url}" "${script_path}" "$@"