Skip to content

Commit 2c06a28

Browse files
committed
allow to run site.build() multiple times in the same process
1 parent 2c3ec89 commit 2c06a28

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Go to the `v1` branch to see the changelog of Lume 1.
1414
- `site.initDebugBar()` to initialize manually the `debugBar`.
1515

1616
### Fixed
17+
- Issues running `site.build()` multiple times in the same process.
1718
- Updated dependencies: `bar`, `unocss`, `tailwindcss`, `esbuild`, `std`, `deno/loader` and some plugins.
1819

1920
## [3.0.6] - 2025-08-07

core/fs.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ export default class FS {
5353
options: Options;
5454
entries = new Map<string, Entry>();
5555
remoteFiles = new Map<string, string>();
56-
tree: Entry;
56+
tree?: Entry;
5757

5858
constructor(options: Options) {
5959
this.options = options;
60-
this.tree = new Entry("", "/", "directory", options.root);
61-
this.entries.set("/", this.tree);
6260
}
6361

6462
init() {
63+
this.tree = new Entry("", "/", "directory", this.options.root);
64+
this.entries.clear();
65+
this.entries.set("/", this.tree);
6566
this.#walkFs(this.tree);
6667
this.#walkRemote();
6768
}
@@ -196,7 +197,10 @@ export default class FS {
196197

197198
addEntry(data: { path: string; type?: EntryType; src?: string }): Entry {
198199
const pieces = data.path.split("/").filter((p) => p);
199-
let parent = this.tree;
200+
let parent = this.tree as Entry;
201+
if (!parent) {
202+
throw new Error("FS not initialized");
203+
}
200204

201205
if (!data.src) {
202206
data.src = posix.join(this.options.root, data.path);

tests/core/scopes.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { assertStrictEquals as equals } from "../../deps/assert.ts";
22
import Scopes from "../../core/scopes.ts";
3-
import FS from "../../core/fs.ts";
3+
import FS, { Entry } from "../../core/fs.ts";
44

55
Deno.test("Scripts", async (t) => {
66
const scopes = new Scopes();
@@ -11,6 +11,7 @@ Deno.test("Scripts", async (t) => {
1111
root: "/",
1212
});
1313

14+
fs.tree = new Entry("", "/", "directory", "/");
1415
fs.addEntry({ path: "/file1.foo", type: "file" });
1516
fs.addEntry({ path: "/file2.bar", type: "file" });
1617
fs.addEntry({ path: "/file3.css", type: "file" });

0 commit comments

Comments
 (0)