This is an automated email from the ASF dual-hosted git repository.

GitToTheHub pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-paramedic.git


The following commit(s) were added to refs/heads/master by this push:
     new 63fd0bb  fix: pass plugin install args as separate argv entries (#314)
63fd0bb is described below

commit 63fd0bb268da8b336134d128d46c04596414e037
Author: Maxim Belov <[email protected]>
AuthorDate: Thu Aug 13 17:01:10 2026 +0200

    fix: pass plugin install args as separate argv entries (#314)
    
    installSinglePlugin already separates a plugin path from any trailing `--` 
arguments, but then concatenates them back into one string and passes that as a 
single argv entry to `cordova plugin add`. The CLI reads the whole thing as one 
plugin spec: `npm error path /abs/path/plugin --variable 
APP_ID=123/package.json`
    
    So `--plugin "./my-plugin --variable APP_ID=123"` cannot install a plugin 
that declares mandatory variables, which is every plugin whose `<preference>` 
elements have no `default`. Splitting the arguments and spreading them makes 
the documented form work.
    
    Plugins without variables are unaffected: with no ` --` in the string the 
argument list is empty and the spawn is byte-identical to before.
    
    One limitation worth noting: arguments are split on whitespace, so a 
variable value containing a space still cannot be passed. That matches the 
existing ` --` heuristic in the same function; handling it properly would need 
shell-style tokenisation and seemed out of scope here.
    
    Generated-by: Claude Opus 5 (Anthropic)
---
 lib/PluginsManager.js | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/PluginsManager.js b/lib/PluginsManager.js
index 9bb0545..3c36a5a 100644
--- a/lib/PluginsManager.js
+++ b/lib/PluginsManager.js
@@ -65,28 +65,30 @@ class PluginsManager {
      */
     async installSinglePlugin (plugin) {
         let pluginPath = plugin;
-        let args = '';
+        let args = [];
 
         // separate plugin name from args
         const argsIndex = plugin.indexOf(' --');
         if (argsIndex > 0) {
             pluginPath = plugin.substring(0, argsIndex);
-            args = plugin.substring(argsIndex);
+            // Each arg has to stay a separate argv entry. Appending them to 
the plugin
+            // path instead leaves the CLI treating the whole string as one 
plugin spec.
+            args = plugin.substring(argsIndex).trim().split(/\s+/);
         }
 
         if (fs.existsSync(path.resolve(this.storedCWD, pluginPath))) {
-            plugin = path.resolve(this.storedCWD, pluginPath) + args;
+            pluginPath = path.resolve(this.storedCWD, pluginPath);
         }
 
         const results = await spawnAsync(
             this.config.getCli(),
-            ['plugin', 'add', plugin, ...utilities.PARAMEDIC_COMMON_ARGS],
+            ['plugin', 'add', pluginPath, ...args, 
...utilities.PARAMEDIC_COMMON_ARGS],
             { cwd: this.appRoot }
         );
 
         if (results.code !== 0) {
-            logger.error(`[paramedic] Failed to install plugin: ${plugin}`);
-            throw new Error(`[paramedic] Failed to install plugin: ${plugin}`);
+            logger.error(`[paramedic] Failed to install plugin: 
${pluginPath}`);
+            throw new Error(`[paramedic] Failed to install plugin: 
${pluginPath}`);
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to