mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 15:59:30 +00:00
test(sdk): resolve npm runner in package e2e
This commit is contained in:
parent
c67bb1c5aa
commit
c6d9977902
1 changed files with 23 additions and 8 deletions
|
|
@ -6,6 +6,7 @@ import { createServer, type Server } from "node:http";
|
|||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { resolveNpmRunner } from "../../../scripts/npm-runner.mjs";
|
||||
import { createPnpmRunnerSpawnSpec } from "../../../scripts/pnpm-runner.mjs";
|
||||
import { getWindowsSystem32ExePath } from "../../../src/infra/windows-install-roots.js";
|
||||
import { createNodeEvalArgs } from "../../../src/test-utils/node-process.js";
|
||||
|
|
@ -162,6 +163,24 @@ function runPnpmCommand(
|
|||
});
|
||||
}
|
||||
|
||||
function runNpmCommand(
|
||||
args: string[],
|
||||
options: { cwd: string; timeoutMs?: number },
|
||||
): Promise<CommandResult> {
|
||||
const env = createCommandEnv();
|
||||
const runner = resolveNpmRunner({
|
||||
env,
|
||||
npmArgs: args,
|
||||
});
|
||||
return runCommand(runner.command, runner.args, {
|
||||
cwd: options.cwd,
|
||||
env: runner.env ?? env,
|
||||
shell: runner.shell,
|
||||
timeoutMs: options.timeoutMs,
|
||||
windowsVerbatimArguments: runner.windowsVerbatimArguments,
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeWorkspaceDependencies(
|
||||
dependencies: Record<string, string> | undefined,
|
||||
): Record<string, string> | undefined {
|
||||
|
|
@ -340,7 +359,7 @@ describe("OpenClaw SDK package e2e", () => {
|
|||
}
|
||||
for (const packageRoot of packageRoots) {
|
||||
const stagingRoot = await createPackStagingRoot(packageRoot, tempDir);
|
||||
await runCommand("npm", ["pack", "--ignore-scripts", "--pack-destination", tempDir], {
|
||||
await runNpmCommand(["pack", "--ignore-scripts", "--pack-destination", tempDir], {
|
||||
cwd: stagingRoot,
|
||||
});
|
||||
}
|
||||
|
|
@ -363,13 +382,9 @@ describe("OpenClaw SDK package e2e", () => {
|
|||
);
|
||||
await fs.writeFile(path.join(tempDir, ".npmrc"), `@openclaw:registry=${registry.registryUrl}`);
|
||||
try {
|
||||
await runCommand(
|
||||
"npm",
|
||||
["install", "--ignore-scripts", "--no-audit", "--no-fund", sdkTarball],
|
||||
{
|
||||
cwd: tempDir,
|
||||
},
|
||||
);
|
||||
await runNpmCommand(["install", "--ignore-scripts", "--no-audit", "--no-fund", sdkTarball], {
|
||||
cwd: tempDir,
|
||||
});
|
||||
} finally {
|
||||
await registry.close();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue