better gitignore
Some checks failed
CI / check (push) Has been cancelled

This commit is contained in:
2026-06-16 10:44:40 +02:00
parent d5dbf7187d
commit 7c69853e85
13 changed files with 171 additions and 86 deletions

View File

@@ -49,19 +49,22 @@ const THEME_TEMPLATE = `/* Helder theme — custom CSS applied OVER the built-in
/** Recently-opened files, newest first. Local machine state — git-ignored. */
const RECENT_FILE = 'recent.json'
const MAX_RECENT = 100
const GITIGNORE_BODY = `# Helder — local, machine-specific state (do not commit)\n${RECENT_FILE}\n`
// The whole .helder folder is local, machine-specific state — ignore all of it.
const GITIGNORE_BODY = `# Helder — local, machine-specific state (do not commit).\n*\n`
let current: HelderConfig = DEFAULTS
let themeCss = ''
/** Create `.helder/.gitignore` (ignoring recent.json) only when it's missing. */
/** Ensure `.helder/.gitignore` ignores the entire folder; (re)write it when the
* file is missing or out of date (e.g. upgrading from the old recent-only one). */
async function ensureGitignore(dir: string): Promise<void> {
const path = join(dir, '.gitignore')
try {
await readFile(path, 'utf8')
if ((await readFile(path, 'utf8')) === GITIGNORE_BODY) return
} catch {
await writeFile(path, GITIGNORE_BODY)
/* missing — fall through to write */
}
await writeFile(path, GITIGNORE_BODY)
}
export async function getRecent(root: string): Promise<string[]> {