shankari edited a comment on issue #87:
URL: https://github.com/apache/cordova-fetch/issues/87#issuecomment-657978818


   The npm install command is launched using `superspawn.spawn`.
   
   And now I come to the part that I don't understand. If I use `-d`, I can see 
the arguments passed in to `npm install`
   
   <details>
   <summary>Command line arguments for npm install</summary>
   
   ```
   No scripts found for hook "before_plugin_add".
   Calling plugman.fetch on plugin 
"https://github.com/phonegap/phonegap-plugin-contentsync.git";
   fetch: Installing 
https://github.com/phonegap/phonegap-plugin-contentsync.git to 
/Users/kshankar/e-mission/upgrade_platform
   Running command: npm install 
https://github.com/phonegap/phonegap-plugin-contentsync.git --production --save
   Command finished with error code 0: npm 
install,https://github.com/phonegap/phonegap-plugin-contentsync.git,--production,--save
   Failed to fetch plugin 
https://github.com/phonegap/phonegap-plugin-contentsync.git via registry.
   Probably this is either a connection problem, or plugin spec is incorrect.
   Check your connection and plugin name/version/URL.
   Could not determine package name from output:
   [email protected] node_modules/phonegap-plugin-contentsync
   CordovaError: Failed to fetch plugin 
https://github.com/phonegap/phonegap-plugin-contentsync.git via registry.
   Probably this is either a connection problem, or plugin spec is incorrect.
   Check your connection and plugin name/version/URL.
   Could not determine package name from output:
   [email protected] node_modules/phonegap-plugin-contentsync
       at 
/Users/kshankar/e-mission/upgrade_platform/node_modules/cordova-lib/src/plugman/fetch.js:146:43
       at processTicksAndRejections (internal/process/task_queues.js:97:5)
   ```
   </details>
   
   If I run the exact same command using superspawn using the node REPL, I get 
an output with the `+`
   
   <details>
   <summary>running same command in node REPL</summary>
   
   ```
   $ node
   Welcome to Node.js v14.5.0.
   Type ".help" for more information.
   > var superspawn = require('cordova-common').superspawn;
   undefined
   > var dest = "<redacted>"
   undefined
   > var args = ["install", 
"https://github.com/phonegap/phonegap-plugin-contentsync.git";, "--production", 
"--save"]
   undefined
   > superspawn.spawn('npm', args, { cwd: dest }).then(function(output){ 
console.log(output); });
   Promise {
     promiseDispatch: [Function (anonymous)],
     valueOf: [Function (anonymous)],
     inspect: [Function (anonymous)]
   }
   > (node:59879) [DEP0097] DeprecationWarning: Using a domain property in 
MakeCallback is deprecated. Use the async_context variant of MakeCallback or 
the AsyncResource class instead.
   (Use `node --trace-deprecation ...` to show where the warning was created)
   + [email protected]
   updated 1 package and audited 1707 packages in 11.991s
   
   47 packages are looking for funding
     run `npm fund` for details
   
   found 173 vulnerabilities (45 low, 75 moderate, 53 high)
     run `npm audit fix` to fix them, or `npm audit` for details
   ```
   </details>
   
   But if I add the same kind of output logging in `fetch.js`, it returns the 
output without the `+`
   
   e.g. if I change the code to 
   
   <details>
   <summary>New code</summary>
   
   ```
   function installPackage (target, dest, opts) {
       return isNpmInstalled()
           // Ensure that `npm` installs to `dest` and not any of its ancestors
           .then(_ => fs.ensureDir(path.join(dest, 'node_modules')))
   
           // Run `npm` to install requested package
           .then(_ => npmArgs(target, opts))
           .then(args => {
               events.emit('verbose', `fetch: Installing ${target} to ${dest}`);
               return superspawn.spawn('npm', args, { cwd: dest });
           })
           .then(function(output){ console.log("Output = "+output); return 
output; })
   
           // Resolve path to installed package
           .then(getTargetPackageSpecFromNpmInstallOutput)
           .then(spec => pathToInstalledPackage(spec, dest));
   }
   ```
   </details>
   
   I get the following output
   
   <details>
   <summary>non-REPL usage</summary
   
   ```
   $ npx cordova plugin -d add 
https://github.com/phonegap/phonegap-plugin-contentsync.git
   No scripts found for hook "before_plugin_add".
   Calling plugman.fetch on plugin 
"https://github.com/phonegap/phonegap-plugin-contentsync.git";
   fetch: Installing 
https://github.com/phonegap/phonegap-plugin-contentsync.git to 
/Users/kshankar/e-mission/upgrade_platform
   Running command: npm install 
https://github.com/phonegap/phonegap-plugin-contentsync.git --production --save
   Command finished with error code 0: npm 
install,https://github.com/phonegap/phonegap-plugin-contentsync.git,--production,--save
   Output = [email protected] 
node_modules/phonegap-plugin-contentsync
   Failed to fetch plugin 
https://github.com/phonegap/phonegap-plugin-contentsync.git via registry.
   Probably this is either a connection problem, or plugin spec is incorrect.
   Check your connection and plugin name/version/URL.
   Could not determine package name from output:
   [email protected] node_modules/phonegap-plugin-contentsync
   CordovaError: Failed to fetch plugin 
https://github.com/phonegap/phonegap-plugin-contentsync.git via registry.
   Probably this is either a connection problem, or plugin spec is incorrect.
   Check your connection and plugin name/version/URL.
   Could not determine package name from output:
   [email protected] node_modules/phonegap-plugin-contentsync
       at 
/Users/kshankar/e-mission/upgrade_platform/node_modules/cordova-lib/src/plugman/fetch.js:146:43
       at processTicksAndRejections (internal/process/task_queues.js:97:5)
   ```
   </details>
   
   I can't figure out why `superspawn` behaves differently in the REPL and in 
the script. Any thoughts?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to