Further iteration
This commit is contained in:
@@ -10,6 +10,7 @@ import { path } from "../common/deps.ts";
|
||||
|
||||
Deno.test("Test plug run", async () => {
|
||||
// const tempDir = await Deno.makeTempDir();
|
||||
const tempDbFile = await Deno.makeTempFile({ suffix: ".db" });
|
||||
|
||||
const assetBundle = new AssetBundle(assets);
|
||||
|
||||
@@ -26,6 +27,7 @@ Deno.test("Test plug run", async () => {
|
||||
assertEquals(
|
||||
await runPlug(
|
||||
testSpaceFolder,
|
||||
tempDbFile,
|
||||
"test.run",
|
||||
[],
|
||||
assetBundle,
|
||||
@@ -35,4 +37,5 @@ Deno.test("Test plug run", async () => {
|
||||
|
||||
// await Deno.remove(tempDir, { recursive: true });
|
||||
esbuild.stop();
|
||||
await Deno.remove(tempDbFile);
|
||||
});
|
||||
|
||||
+2
-13
@@ -9,16 +9,13 @@ import { AssetBundlePlugSpacePrimitives } from "../common/spaces/asset_bundle_sp
|
||||
|
||||
export async function runPlug(
|
||||
spacePath: string,
|
||||
dbPath: string,
|
||||
functionName: string | undefined,
|
||||
args: string[] = [],
|
||||
builtinAssetBundle: AssetBundle,
|
||||
indexFirst = false,
|
||||
httpServerPort = 3123,
|
||||
httpHostname = "127.0.0.1",
|
||||
) {
|
||||
spacePath = path.resolve(spacePath);
|
||||
const tempFile = Deno.makeTempFileSync({ suffix: ".db" });
|
||||
console.log("Tempt db file", tempFile);
|
||||
const serverController = new AbortController();
|
||||
const app = new Application();
|
||||
|
||||
@@ -27,7 +24,7 @@ export async function runPlug(
|
||||
new DiskSpacePrimitives(spacePath),
|
||||
builtinAssetBundle,
|
||||
),
|
||||
tempFile,
|
||||
dbPath,
|
||||
app,
|
||||
);
|
||||
await serverSystem.init();
|
||||
@@ -37,13 +34,6 @@ export async function runPlug(
|
||||
signal: serverController.signal,
|
||||
});
|
||||
|
||||
if (indexFirst) {
|
||||
await serverSystem.system.loadedPlugs.get("index")!.invoke(
|
||||
"reindexSpace",
|
||||
[],
|
||||
);
|
||||
}
|
||||
|
||||
if (functionName) {
|
||||
const [plugName, funcName] = functionName.split(".");
|
||||
|
||||
@@ -54,7 +44,6 @@ export async function runPlug(
|
||||
const result = await plug.invoke(funcName, args);
|
||||
await serverSystem.close();
|
||||
serverSystem.denoKv.close();
|
||||
await Deno.remove(tempFile);
|
||||
serverController.abort();
|
||||
return result;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user