mirror of
https://github.com/lutinglt/gitea-github-theme.git
synced 2025-10-27 13:40:31 +00:00
简化
This commit is contained in:
43
build.ts
Executable file
43
build.ts
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env -S deno run -A --allow-scripts
|
||||
|
||||
import * as sass from "npm:sass";
|
||||
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 buildTheme(themePath: string) {
|
||||
try {
|
||||
const inputFile = "sass/theme-github.scss";
|
||||
const outputFile = "dist/theme-github.css";
|
||||
|
||||
const result = await sass.compileAsync(inputFile, { sourceMap: false, style: "compressed" });
|
||||
await Deno.writeTextFile(outputFile, result.css);
|
||||
|
||||
const fileContent = await Deno.readTextFile(themePath);
|
||||
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("Build failed:", e);
|
||||
Deno.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
buildTheme("theme.yml");
|
||||
Reference in New Issue
Block a user