nodejs->deno

This commit is contained in:
lutinglt
2025-02-13 01:13:32 +08:00
parent c0d181278f
commit 34f72da8b5
10 changed files with 61 additions and 75 deletions

37
version.ts Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env -S deno run -A
import * as yaml from "npm:js-yaml";
interface Asset {
name: string;
css: string;
}
interface Theme {
version: string;
theme: string;
description: string;
assets: Asset[];
}
interface Gitea {
gitea: Theme;
}
async function readYamlFile(filePath: string) {
try {
const fileContent = await Deno.readTextFile(filePath);
const data: Gitea = yaml.load(fileContent);
console.log(data.gitea.version);
} catch (error) {
let e = error;
if (error instanceof Error) {
e = error.message;
}
console.error("Error reading or parsing YAML file:", e);
Deno.exit(1);
}
}
// 使用示例
readYamlFile("theme.yml");