chore(dev): support .copy-files.local override for copy-files and ignore it

This commit is contained in:
renatomen 2025-08-13 00:33:12 +00:00
parent b2b4c7ada0
commit 958ff60699
2 changed files with 18 additions and 3 deletions

9
.gitignore vendored
View file

@ -1,5 +1,5 @@
# vscode
.vscode
.vscode
# Intellij
*.iml
@ -44,3 +44,10 @@ plans
# Project planning files
project
# Exclude local test vaults and e2e cache artifacts
external/tasknotes-e2e/.e2e/
C/
.copy-files.local

View file

@ -1,13 +1,21 @@
#!/usr/bin/env node
import { copyFile, mkdir, access, constants } from 'fs/promises';
import { copyFile, mkdir, access, constants, readFile } from 'fs/promises';
import { join, resolve } from 'path';
import os from 'os';
// Default copy destination - can be overridden with OBSIDIAN_PLUGIN_PATH environment variable
// Use os.homedir() to avoid literal "$HOME" not being expanded by Node
const defaultPath = join(os.homedir(), 'testvault', 'test', '.obsidian', 'plugins', 'tasknotes');
const copyPath = process.env.OBSIDIAN_PLUGIN_PATH || defaultPath;
const LOCAL_OVERRIDE_FILE = '.copy-files.local';
let copyPath = process.env.OBSIDIAN_PLUGIN_PATH || defaultPath;
try {
const local = await readFile(LOCAL_OVERRIDE_FILE, 'utf8');
const trimmed = local.trim();
if (trimmed) copyPath = trimmed;
} catch (_) {
// no local override
}
// Files to copy after build
const files = ['main.js', 'styles.css', 'manifest.json'];