Skip to content

Commit f50a1a5

Browse files
committed
call run in load
1 parent c38290e commit f50a1a5

File tree

5 files changed

+4
-9
lines changed

5 files changed

+4
-9
lines changed

TODO.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
call `run` in `load`
21
rename `run/` to `load/`
32

43
call `handleImport` after `handleDefine` -- to support circular imports

src/commands/runCommand.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type Command } from "@xieyuheng/commander.js"
22
import fs from "fs"
33
import Path from "path"
4-
import { load, run } from "../lang/run/index.ts"
4+
import { load } from "../lang/run/index.ts"
55

66
export const runCommand: Command = {
77
name: "run",
@@ -19,8 +19,7 @@ export const runCommand: Command = {
1919
const url = createURL(String(commander.args[0]))
2020

2121
try {
22-
const mod = await load(url)
23-
await run(mod)
22+
await load(url)
2423
} catch (error) {
2524
if (error instanceof Error) {
2625
console.error(error.message)

src/lang/run/handleImport.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { modDefine, modFind, modResolve } from "../mod/index.ts"
22
import type { Mod } from "../mod/Mod.ts"
33
import type { ImportEntry, Stmt } from "../stmt/Stmt.ts"
44
import { globalLoadedMods } from "./globalLoadedMods.ts"
5-
import { run } from "./run.ts"
65

76
export async function handleImport(mod: Mod, stmt: Stmt): Promise<void> {
87
if (stmt.kind === "Import") {
@@ -29,8 +28,6 @@ async function importOne(
2928
throw new Error(`Mod is not loaded: ${path}`)
3029
}
3130

32-
await run(found.mod)
33-
3431
const { name, rename } = entry
3532

3633
const def = modFind(found.mod, name)

src/lang/run/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
export * from "./globalLoadedMods.ts"
21
export * from "./load.ts"
3-
export * from "./run.ts"

src/lang/run/load.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import fs from "node:fs"
33
import { createMod, modResolve, type Mod } from "../mod/index.ts"
44
import { parseStmts } from "../parse/index.ts"
55
import { globalLoadedMods } from "./globalLoadedMods.ts"
6+
import { run } from "./run.ts"
67

78
export async function load(url: URL): Promise<Mod> {
89
const found = globalLoadedMods.get(url.href)
@@ -24,6 +25,7 @@ export async function load(url: URL): Promise<Mod> {
2425
}
2526
}
2627

28+
await run(mod)
2729
return mod
2830
} catch (error) {
2931
if (error instanceof ParsingError) {

0 commit comments

Comments
 (0)