fix: support scoped npm plugins (#3785)

Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
This commit is contained in:
Err
2025-11-04 09:15:01 -06:00
committed by GitHub
parent aec44abcf6
commit 6f0028644e
3 changed files with 63 additions and 2 deletions

View File

@@ -34,8 +34,10 @@ export namespace Plugin {
for (let plugin of plugins) {
log.info("loading plugin", { path: plugin })
if (!plugin.startsWith("file://")) {
const [pkg, version] = plugin.split("@")
plugin = await BunProc.install(pkg, version ?? "latest")
const lastAtIndex = plugin.lastIndexOf("@")
const pkg = lastAtIndex > 0 ? plugin.substring(0, lastAtIndex) : plugin
const version = lastAtIndex > 0 ? plugin.substring(lastAtIndex + 1) : "latest"
plugin = await BunProc.install(pkg, version)
}
const mod = await import(plugin)
for (const [_name, fn] of Object.entries<PluginInstance>(mod)) {