From 324b38e90e0e8bfc571e78b6ea24413e05c36f61 Mon Sep 17 00:00:00 2001 From: Denys Halenok Date: Tue, 19 Mar 2024 08:21:48 +0100 Subject: [PATCH] Allow installing local and remote plugins simultaneously --- bin/installPlugins.ts | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/bin/installPlugins.ts b/bin/installPlugins.ts index 8a6a71345..2d4f63355 100644 --- a/bin/installPlugins.ts +++ b/bin/installPlugins.ts @@ -10,18 +10,19 @@ if (process.argv.length === 2) { process.exit(1); } -let plugins = process.argv.slice(2) -let installFromPath = false; +let args = process.argv.slice(2) -const thirdOptPlug = plugins[0] +let registryPlugins: string[] = []; +let localPlugins: string[] = []; -console.log("Third option: ", thirdOptPlug) -if (thirdOptPlug && thirdOptPlug.includes('path')) { - installFromPath = true - plugins.splice(plugins.indexOf('--path'), 1); +if (args.indexOf('--path') !== -1) { + const indexToSplit = args.indexOf('--path'); + registryPlugins = args.slice(0, indexToSplit); + localPlugins = args.slice(indexToSplit + 1); +} else { + registryPlugins = args; } - const persistInstalledPlugins = async () => { const plugins:PackageData[] = [] const installedPlugins = {plugins: plugins}; @@ -36,15 +37,15 @@ const persistInstalledPlugins = async () => { }; async function run() { - for (const plugin of plugins) { - if(installFromPath) { - console.log(`Installing plugin from path: ${plugin}`); - await linkInstaller.installFromPath(plugin); - continue; - } + for (const plugin of registryPlugins) { console.log(`Installing plugin from registry: ${plugin}`) await linkInstaller.installPlugin(plugin); } + + for (const plugin of localPlugins) { + console.log(`Installing plugin from path: ${plugin}`); + await linkInstaller.installFromPath(plugin); + } } (async () => {