fix(plugin): build plugins when dist is ignored

This commit is contained in:
saberzero1 2026-03-16 11:49:15 +01:00
parent 1b878e655e
commit f8c9a2926d
No known key found for this signature in database

View File

@ -86,7 +86,24 @@ async function runParallel(items, concurrency, fn) {
return results
}
/**
* Check whether a plugin's .gitignore excludes dist/.
* When dist/ is gitignored, the plugin cannot ship pre-built output in version
* control (e.g. because it uses tree-shaking) and must always be built locally.
*/
function isDistGitignored(pluginDir) {
const gitignorePath = path.join(pluginDir, ".gitignore")
if (!fs.existsSync(gitignorePath)) return false
const lines = fs.readFileSync(gitignorePath, "utf-8").split("\n")
return lines.some((line) => {
const trimmed = line.trim()
return trimmed === "dist" || trimmed === "dist/" || trimmed === "/dist" || trimmed === "/dist/"
})
}
function needsBuild(pluginDir) {
if (isDistGitignored(pluginDir)) return true
const distDir = path.join(pluginDir, "dist")
return !fs.existsSync(distDir)
}