Skip to content

Commit 7aeaae8

Browse files
authored
Fix js-yaml named imports
1 parent 2bd26b0 commit 7aeaae8

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

lib/lesson-discovery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readdir, readFile } from "node:fs/promises";
22
import { existsSync } from "node:fs";
33
import { join } from "node:path";
4-
import yaml from "js-yaml";
4+
import { load } from "js-yaml";
55
import {
66
moduleFileSchema,
77
parseOrderedName,
@@ -67,7 +67,7 @@ export async function discoverLessons(): Promise<LessonEntry[]> {
6767
throw new Error(`${modDir.name}: missing module.yaml`);
6868
}
6969
const moduleFile = moduleFileSchema.parse(
70-
yaml.load(await readFile(moduleYamlPath, "utf8")),
70+
load(await readFile(moduleYamlPath, "utf8")),
7171
);
7272
const moduleMeta: ModuleMeta = {
7373
slug: parsedMod.slug,

lib/lessons.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { readFile } from "node:fs/promises";
33
import { existsSync } from "node:fs";
44
import { join } from "node:path";
55
import { cache } from "react";
6-
import yaml from "js-yaml";
6+
import { load } from "js-yaml";
77
import {
88
lessonFileSchema,
99
type Check,
@@ -27,7 +27,7 @@ async function loadOne(entry: LessonEntry): Promise<Lesson> {
2727
if (!existsSync(yamlPath)) throw new Error(`${slug}: missing lesson.yaml`);
2828
if (!existsSync(mdxPath)) throw new Error(`${slug}: missing lesson.mdx`);
2929

30-
const file = lessonFileSchema.parse(yaml.load(await readFile(yamlPath, "utf8")));
30+
const file = lessonFileSchema.parse(load(await readFile(yamlPath, "utf8")));
3131
const meta: LessonMeta = { ...file, slug, order, module: moduleMeta };
3232

3333
const mdxSource = await readFile(mdxPath, "utf8");

scripts/prepare-templates.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { config } from "dotenv";
2222
import { readFile } from "node:fs/promises";
2323
import { existsSync } from "node:fs";
2424
import { join } from "node:path";
25-
import yaml from "js-yaml";
25+
import { load } from "js-yaml";
2626
import { Client } from "pg";
2727
import { lessonFileSchema } from "../lib/lesson-schema";
2828
import { discoverLessons } from "../lib/lesson-discovery";
@@ -51,7 +51,7 @@ async function loadLessonSeeds(): Promise<LessonSeed[]> {
5151
for (const { slug, dir } of entries) {
5252
const yamlPath = join(dir, "lesson.yaml");
5353
if (!existsSync(yamlPath)) throw new Error(`${slug}: missing lesson.yaml`);
54-
const meta = lessonFileSchema.parse(yaml.load(await readFile(yamlPath, "utf8")));
54+
const meta = lessonFileSchema.parse(load(await readFile(yamlPath, "utf8")));
5555
const seedPath = join(dir, meta.seed);
5656
const seedSql = existsSync(seedPath) ? await readFile(seedPath, "utf8") : "";
5757
if (!seedSql.trim()) throw new Error(`${slug}: seed "${meta.seed}" is empty`);

scripts/validate-lessons.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { readFile } from "node:fs/promises";
1818
import { existsSync } from "node:fs";
1919
import { join } from "node:path";
20-
import yaml from "js-yaml";
20+
import { load } from "js-yaml";
2121
import { lessonFileSchema } from "../lib/lesson-schema";
2222
import { discoverLessons, type LessonEntry } from "../lib/lesson-discovery";
2323

@@ -36,7 +36,7 @@ async function validateOne(entry: LessonEntry): Promise<Result> {
3636

3737
let meta;
3838
try {
39-
meta = lessonFileSchema.parse(yaml.load(await readFile(yamlPath, "utf8")));
39+
meta = lessonFileSchema.parse(load(await readFile(yamlPath, "utf8")));
4040
} catch (err) {
4141
errors.push(`lesson.yaml invalid: ${(err as Error).message}`);
4242
return { slug, ok: false, errors };

0 commit comments

Comments
 (0)