Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 0 additions & 58 deletions lib/std.yaml.ts

This file was deleted.

14 changes: 3 additions & 11 deletions load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export interface LoadOptions {
export function* load(options: LoadOptions): Operation<PSModule> {
let { location, base } = options;
let url = typeof location === "string" ? new URL(location, base) : location;
let body = yield* fetchModule(url);

let content = yield* read(url);
let body = parse(content);

let result: PSValue = body;

Expand Down Expand Up @@ -117,16 +119,6 @@ export function* load(options: LoadOptions): Operation<PSModule> {
};
}

function* fetchModule(url: URL): Operation<PSValue> {
if (url.pathname.endsWith(".ts") || url.pathname.endsWith(".js")) {
let definition = yield* expect(import(url.toString()));
return definition.default;
} else {
let content = yield* read(url);
return parse(content);
}
}

function* read(url: URL): Operation<string> {
if (url.protocol === "file:") {
return yield* expect(Deno.readTextFile(url));
Expand Down
14 changes: 1 addition & 13 deletions test/module.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import type { PSModule } from "../types.ts";
import type { Task } from "../deps.ts";

import {
describe,
evaluate,
expect,
it,
useStaticFileServer,
} from "./suite.ts";
import { describe, expect, it, useStaticFileServer } from "./suite.ts";
import { load, ps2js } from "../mod.ts";
import { run } from "../deps.ts";
import { lookup, lookup$ } from "../psmap.ts";
Expand Down Expand Up @@ -47,12 +41,6 @@ describe("a PlatformScript module", () => {
}
});

it("can be specified using a TypeScript module", async () => {
let mod = await loadmod("module.yaml.ts");
let result = await evaluate(`{$to-string: 100 }`, mod.symbols);
expect(result).toEqual({ type: "string", value: "100", holes: [] });
});

it("can support a `do` expression at the module level", async () => {
let mod = await loadmod("do.yaml");
expect(ps2js(mod.value)).toEqual("hello from do");
Expand Down
64 changes: 0 additions & 64 deletions test/modules/module.yaml.ts

This file was deleted.