Refine CLI service and align project metadata
This commit is contained in:
1 parent
802c32c6bd
commit
2ca45d935e
11 files changed
+285
-184
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { serviceStatus } from "./service.js";
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
afterEach(() => {
|
||||
for (const dir of tempDirs.splice(0)) {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
describe("service lifecycle state", () => {
|
||||
test("clears a stale pid file instead of reporting another process as running", () => {
|
||||
const stateDir = mkdtempSync(join(tmpdir(), "seal-home-service-"));
|
||||
tempDirs.push(stateDir);
|
||||
writeFileSync(join(stateDir, "service.pid"), "999999\n");
|
||||
|
||||
const status = serviceStatus({
|
||||
appRoot: "/tmp/seal-home",
|
||||
entryFile: "/tmp/seal-home/src/cli.ts",
|
||||
stateDir,
|
||||
version: "0.4.2"
|
||||
});
|
||||
|
||||
expect(status.running).toBe(false);
|
||||
expect(status.pid).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user