mirror of
https://github.com/expo/agent-cli-detector.git
synced 2026-11-14 08:38:15 -10:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a6a5df31d | ||
|
|
57027fd556 | ||
|
|
a594f0d389 |
No files matched your search
@@ -1,6 +1,7 @@
|
||||
name: test
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
push:
|
||||
|
||||
|
||||
+1
-1
@@ -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
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user