mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-08 07:41:08 +00:00
test: normalize owning npm path assertions
This commit is contained in:
@@ -751,6 +751,12 @@ describe("update-cli", () => {
|
||||
const brewRoot = path.join(brewPrefix, "lib", "node_modules");
|
||||
const pkgRoot = path.join(brewRoot, "openclaw");
|
||||
const brewNpm = path.join(brewPrefix, "bin", "npm");
|
||||
const win32PrefixNpm = path.join(brewPrefix, "npm.cmd");
|
||||
const owningNpmCommands = new Set(
|
||||
[brewNpm, path.resolve(brewNpm), win32PrefixNpm, path.resolve(win32PrefixNpm)].map(
|
||||
(candidate) => path.normalize(candidate),
|
||||
),
|
||||
);
|
||||
const pathNpmRoot = createCaseDir("nvm-root");
|
||||
mockPackageInstallStatus(pkgRoot);
|
||||
pathExists.mockResolvedValue(false);
|
||||
@@ -776,7 +782,11 @@ describe("update-cli", () => {
|
||||
termination: "exit",
|
||||
};
|
||||
}
|
||||
if (argv[0] === brewNpm && argv[1] === "root" && argv[2] === "-g") {
|
||||
if (
|
||||
owningNpmCommands.has(path.normalize(String(argv[0] ?? ""))) &&
|
||||
argv[1] === "root" &&
|
||||
argv[2] === "-g"
|
||||
) {
|
||||
return {
|
||||
stdout: `${brewRoot}\n`,
|
||||
stderr: "",
|
||||
@@ -808,6 +818,7 @@ describe("update-cli", () => {
|
||||
.mock.calls.find(
|
||||
([argv]) =>
|
||||
Array.isArray(argv) &&
|
||||
owningNpmCommands.has(path.normalize(String(argv[0] ?? ""))) &&
|
||||
argv[1] === "i" &&
|
||||
argv[2] === "-g" &&
|
||||
argv[3] === "openclaw@latest",
|
||||
|
||||
Reference in New Issue
Block a user