Skip to content

Commit 68d40dd

Browse files
committed
updated more tests
1 parent 0cdb5a1 commit 68d40dd

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codingap/steve",
3-
"version": "2.0.5",
3+
"version": "2.0.6",
44
"exports": "./index.ts",
55
"description": "STEVE is a configurable template engine that allows JavaScript to run in files to create files. It has a plugin system to allow for custom generation and a built-in site generator.",
66
"tasks": {

src/core/steve.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ class STEVE {
8686

8787
for (const file of walkSync(includePath)) {
8888
if (file.isFile) {
89-
this.#includes[relative(includePath, file.path)] = Deno
89+
this.#includes[
90+
relative(includePath, file.path).replace(/\\/g, '/')
91+
] = Deno
9092
.readTextFileSync(file.path);
9193
}
9294
}

test/steve.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import { assertEquals, assertThrows } from 'jsr:@std/assert';
1111
import { STEVE, STEVEPlugin } from '../index.ts';
12+
import { ensureDir } from '@std/fs';
1213

1314
class MockPlugin extends STEVEPlugin {
1415
override PLUGIN_ID = 'MOCK_PLUGIN';
@@ -39,6 +40,26 @@ Deno.test('STEVE: set and get includeDirectory', async () => {
3940
await Deno.remove(tempDir, { recursive: true });
4041
});
4142

43+
Deno.test('STEVE: includeDirectory handles nested files', async () => {
44+
const tempDir = await Deno.makeTempDir();
45+
const subDir = `${tempDir}/sub`;
46+
await ensureDir(subDir);
47+
const templateFile1 = `${tempDir}/template.html`;
48+
const templateFile2 = `${subDir}/nested.html`;
49+
50+
await Deno.writeTextFile(templateFile1, 'Root Template');
51+
await Deno.writeTextFile(templateFile2, 'Nested Template');
52+
53+
STEVE.includeDirectory = tempDir;
54+
55+
const includes = STEVE.includeDirectory;
56+
assertEquals(Object.keys(includes).length, 2);
57+
assertEquals(includes['template.html'], 'Root Template');
58+
assertEquals(includes['sub/nested.html'], 'Nested Template');
59+
60+
await Deno.remove(tempDir, { recursive: true });
61+
});
62+
4263
Deno.test('STEVE: throw error when no active plugin is set', () => {
4364
assertThrows(
4465
() => STEVE.generate({ key: 'value' }),

0 commit comments

Comments
 (0)