-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.mjs
More file actions
29 lines (22 loc) · 977 Bytes
/
build.mjs
File metadata and controls
29 lines (22 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { readFile, writeFile } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import path from 'node:path';
const root = path.resolve(process.cwd());
const settingsPath = path.join(root, 'settings.yml');
const cssPath = path.join(root, 'composer.css');
const outPath = path.join(root, 'theme.css');
async function main() {
if (!existsSync(settingsPath)) throw new Error('settings.yml not found');
if (!existsSync(cssPath)) throw new Error('composer.css not found');
const settingsRaw = await readFile(settingsPath, 'utf8');
const cssRaw = await readFile(cssPath, 'utf8');
// Wrap YAML back into the annotated comment Obsidian Style Settings expects
const header = '/* @settings\n' + settingsRaw.trimEnd() + '\n*/\n\n';
const output = header + cssRaw.replace(/^[\s\n]*\/\*.*?\*\/\n+/, '');
await writeFile(outPath, output, 'utf8');
console.log('theme.css generated');
}
main().catch(err => {
console.error(err);
process.exit(1);
});