style(coding-agent): reuse fs namespace in HTML export
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import * as fs from "node:fs";
|
||||
import * as fsPromises from "node:fs/promises";
|
||||
import * as path from "node:path";
|
||||
import type { AgentState } from "@oh-my-pi/pi-agent-core";
|
||||
import { APP_NAME, isEnoent } from "@oh-my-pi/pi-utils";
|
||||
@@ -210,7 +209,7 @@ async function collectSubSessionsFromDir(
|
||||
): Promise<void> {
|
||||
let names: string[];
|
||||
try {
|
||||
names = await fsPromises.readdir(dir);
|
||||
names = await fs.promises.readdir(dir);
|
||||
} catch (err) {
|
||||
if (isEnoent(err)) return;
|
||||
throw err;
|
||||
|
||||
@@ -160,9 +160,11 @@ describe("HTML export template", () => {
|
||||
]);
|
||||
expect(exitCode, stderr).toBe(0);
|
||||
const [packResult] = JSON.parse(stdout) as NpmPackResult[];
|
||||
const packedAssets = packResult!.files.map(file => file.path).filter(filePath =>
|
||||
/^dist\/(?:template-[^.]+\.(?:css|html|js)|tool-views\.generated-[^.]+\.js)$/.test(filePath),
|
||||
);
|
||||
const packedAssets = packResult!.files
|
||||
.map(file => file.path)
|
||||
.filter(filePath =>
|
||||
/^dist\/(?:template-[^.]+\.(?:css|html|js)|tool-views\.generated-[^.]+\.js)$/.test(filePath),
|
||||
);
|
||||
expect(packedAssets).toHaveLength(4);
|
||||
expect(packedAssets.filter(filePath => /^dist\/template-[^.]+\.css$/.test(filePath))).toHaveLength(1);
|
||||
expect(packedAssets.filter(filePath => /^dist\/template-[^.]+\.html$/.test(filePath))).toHaveLength(1);
|
||||
|
||||
Reference in New Issue
Block a user