Compare commits

...
Author SHA1 Message Date
David Mokos 5a6a5df31d runs npm smoke test through node 2026-06-25 20:38:18 +02:00
David Mokos 57027fd556 runs node tests without shell globs 2026-06-25 20:36:31 +02:00
David Mokos a594f0d389 adds manual ci workflow dispatch 2026-06-25 19:41:36 +02:00
3 changed files with 13 additions and 5 deletions

No files matched your search

+1
View File
@@ -1,6 +1,7 @@
name: test
on:
workflow_dispatch:
pull_request:
push:
+1 -1
View File
@@ -24,7 +24,7 @@
"scripts": {
"build": "tsc -p tsconfig.json && node -e \"require('node:fs').chmodSync('dist/cli.js', 0o755)\"",
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
"test": "npm run build && node --test test/*.test.mjs",
"test": "npm run build && node --test test/detector.test.mjs test/package.test.mjs",
"prepack": "npm run clean && npm test"
},
"keywords": [
+11 -4
View File
@@ -6,15 +6,13 @@ import path from "node:path";
import { fileURLToPath } from "node:url";
import test from "node:test";
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
const projectRoot = path.resolve(fileURLToPath(new URL("..", import.meta.url)));
test("packed package can be installed, imported, and run as a CLI", () => {
const workspace = mkdtempSync(path.join(tmpdir(), "agent-cli-detector-"));
try {
const packOutput = execFileSync(
npm,
const packOutput = execNpm(
["pack", "--ignore-scripts", "--json", "--pack-destination", workspace],
{
cwd: projectRoot,
@@ -60,7 +58,7 @@ test("packed package can be installed, imported, and run as a CLI", () => {
]);
writeFileSync(path.join(workspace, "package.json"), '{"type":"module"}\n');
execFileSync(npm, ["install", "--ignore-scripts", "--no-audit", "--no-fund", tarball], {
execNpm(["install", "--ignore-scripts", "--no-audit", "--no-fund", tarball], {
cwd: workspace,
stdio: "pipe"
});
@@ -118,3 +116,12 @@ test("packed package can be installed, imported, and run as a CLI", () => {
rmSync(workspace, { recursive: true, force: true });
}
});
function execNpm(args, options) {
if (process.env.npm_execpath !== undefined) {
return execFileSync(process.execPath, [process.env.npm_execpath, ...args], options);
}
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
return execFileSync(npm, args, options);
}