fix(plugins): copy directories recursively in build script

Add copyRecursive() helper function to handle both files and directories
when copying plugin builds to bundled-plugins. This ensures i18n folders
and other directories are properly copied.

Previously, only files were copied (checking isFile()), which caused i18n
folders to be skipped. Now all three plugin build commands (procrastination-
buster, sync-md, ai-productivity-prompts) properly copy directory trees.

Fixes: 404 errors for i18n/de.json and other directory contents
This commit is contained in:
Johannes Millan 2026-01-16 21:18:41 +01:00
parent cbc36012d8
commit 91fe3652dc

View file

@ -22,6 +22,22 @@ function log(message, color = '') {
console.log(`${color}${message}${colors.reset}`);
}
// Recursive copy function that handles both files and directories
function copyRecursive(src, dest) {
const stat = fs.statSync(src);
if (stat.isDirectory()) {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}
const entries = fs.readdirSync(src);
for (const entry of entries) {
copyRecursive(path.join(src, entry), path.join(dest, entry));
}
} else {
fs.copyFileSync(src, dest);
}
}
// Plugin configurations
const plugins = [
{
@ -45,9 +61,7 @@ const plugins = [
for (const file of files) {
const src = path.join(distPath, file);
const dest = path.join(targetDir, file);
if (fs.statSync(src).isFile()) {
fs.copyFileSync(src, dest);
}
copyRecursive(src, dest);
}
}
return 'Built and copied to assets';
@ -114,9 +128,7 @@ const plugins = [
for (const file of files) {
const src = path.join(distPath, file);
const dest = path.join(targetDir, file);
if (fs.statSync(src).isFile()) {
fs.copyFileSync(src, dest);
}
copyRecursive(src, dest);
}
}
return 'Built and copied to assets';
@ -168,9 +180,7 @@ const plugins = [
for (const file of files) {
const src = path.join(distPath, file);
const dest = path.join(targetDir, file);
if (fs.statSync(src).isFile()) {
fs.copyFileSync(src, dest);
}
copyRecursive(src, dest);
}
}
return 'Built and copied to assets';