Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-14133

Avoid reinstalling already installed plugins in cordova-fetch

    Details

    • Type: Wish
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 8.0.0
    • Fix Version/s: None
    • Component/s: cordova-cli, cordova-fetch
    • Labels:
      None

      Description

      Relates to CB-13992

      The pull request for CB-13992 removed the dependency-ls package which helped to speed up the platform add step. However, each plugin still gets npm install ed seemingly just to determine the package name. 

      Typical workflow is to run npm install as the first task after cloning a node repository. The current practice for cordova is to save plugins to the package.json meaning that plugins are already installed to the node_modules directory, so running npm install for each of them individually is redundant.

      If the main function in cordova-fetch is simplified to just return the path to the given module (albeit this isn't the most elegant implementation):

      module.exports = function (target, dest, opts = {}) {
          var fetchArgs = opts.link ? ['link'] : ['list'];
          var nodeModulesDir = dest + '/node_modules/';
      
          // check if npm is installed
          return module.exports.isNpmInstalled()
              .then(function () {
                  const mod = target.slice(0, target.lastIndexOf('@'));
                  return path.resolve(nodeModulesDir, mod)
              })
              .catch(function (err) {
                  throw new CordovaError(err);
              });
      };
      

      the platform add process runs almost instantly rather than taking a few minutes.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                raphinesse Raphael
                Reporter:
                zbarbuto Zak
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: