Resolve exported fixtures through owner roots
This commit is contained in:
parent
4cdfa9c6eb
commit
cd4fc7fad0
1 changed files with 6 additions and 5 deletions
|
|
@ -1,9 +1,10 @@
|
|||
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { compileEveDsl } from "../../web/eve-dsl.js";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
|
||||
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
||||
const kernelRoot = path.resolve(process.env.EVE_KERNEL_ROOT || "E:\\Projects\\Eve");
|
||||
const { compileEveDsl } = await import(pathToFileURL(path.join(kernelRoot, "web/eve-dsl.js")));
|
||||
const manifest = JSON.parse(await readFile(path.join(repoRoot, "tools/parity/parity-manifest.json"), "utf8"));
|
||||
|
||||
const fixtureId = process.argv[2] || "cultui-inspector";
|
||||
|
|
@ -18,7 +19,7 @@ if (!fixture) {
|
|||
throw new Error(`Unknown parity fixture: ${fixtureId}`);
|
||||
}
|
||||
|
||||
const surface = await loadSurface(fixture.surface);
|
||||
const surface = await loadSurface(fixture, fixture.surface);
|
||||
surface.fixtureId = fixture.id;
|
||||
surface.values ||= surface.mesh?.snapshot?.() || {};
|
||||
delete surface.mesh;
|
||||
|
|
@ -27,8 +28,8 @@ await mkdir(path.dirname(outputPath), { recursive: true });
|
|||
await writeFile(outputPath, `${JSON.stringify(surface, null, 2)}\n`);
|
||||
console.log(outputPath);
|
||||
|
||||
async function loadSurface(surface) {
|
||||
const absolutePath = path.join(repoRoot, surface.path);
|
||||
async function loadSurface(owner, surface) {
|
||||
const absolutePath = path.resolve(repoRoot, owner.sourceRoot || ".", surface.path);
|
||||
const source = await readFile(absolutePath, "utf8");
|
||||
if (surface.transport === "local-eve-dsl") return compileEveDsl(source);
|
||||
if (surface.transport === "local-json") return JSON.parse(source);
|
||||
|
|
|
|||
Reference in a new issue