mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-13 14:37:26 +00:00
fix(openontology): resolve manifest directories on Windows (#116)
This commit is contained in:
parent
6f23dbdb0f
commit
e5283455af
2 changed files with 9 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { existsSync, readFileSync } from "node:fs";
|
import { existsSync, readFileSync } from "node:fs";
|
||||||
import { isAbsolute, join, resolve } from "node:path";
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
||||||
import { parse as parseYaml } from "yaml";
|
import { parse as parseYaml } from "yaml";
|
||||||
import { canonicalObject, digest, packageDigest } from "./canonical.js";
|
import { canonicalObject, digest, packageDigest } from "./canonical.js";
|
||||||
import { OPENONTOLOGY_VERSION } from "./types.js";
|
import { OPENONTOLOGY_VERSION } from "./types.js";
|
||||||
|
|
@ -75,7 +75,7 @@ function loadFromDir(dirOrFile: string): LoadedPackage {
|
||||||
? base
|
? base
|
||||||
: findManifest(base);
|
: findManifest(base);
|
||||||
|
|
||||||
const dir = manifestPath.slice(0, manifestPath.lastIndexOf("/")) || ".";
|
const dir = dirname(manifestPath);
|
||||||
const manifest = canonicalObject(parseFile(manifestPath) as Manifest);
|
const manifest = canonicalObject(parseFile(manifestPath) as Manifest);
|
||||||
|
|
||||||
if (manifest?.kind !== "OntologyPackage") {
|
if (manifest?.kind !== "OntologyPackage") {
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,13 @@ describe("init + validate", () => {
|
||||||
expect(pkg.files.map((f) => f.path)).toContain("data/claims.ndjson");
|
expect(pkg.files.map((f) => f.path)).toContain("data/claims.ndjson");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("loads a package from an explicit manifest path", () => {
|
||||||
|
const { dir } = scaffold();
|
||||||
|
const pkg = loadOntologyPackage(join(dir, "openontology.yaml"));
|
||||||
|
expect(pkg.dir).toBe(dir);
|
||||||
|
expect(pkg.manifest.id).toBe("test-ecosystem");
|
||||||
|
});
|
||||||
|
|
||||||
it("builds a deterministic digest that survives a rebuild", () => {
|
it("builds a deterministic digest that survives a rebuild", () => {
|
||||||
const { pkg } = scaffold();
|
const { pkg } = scaffold();
|
||||||
const first = buildOntologyPackage(pkg);
|
const first = buildOntologyPackage(pkg);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue