Github user vladimir-kotikov commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/498#discussion_r82563323
  
    --- Diff: cordova-lib/src/util/npm-helper.js ---
    @@ -72,4 +75,53 @@ function restoreSettings() {
         }
     }
     
    +/**
    + * Fetches the latest version of a package from NPM that matches the 
specified version. Returns a promise that
    + * resolves to the directory the NPM package is located in.
    + * @param packageName - name of an npm package
    + * @param packageVersion - requested version or version range
    + */
    +function fetchPackage(packageName, packageVersion) {
    +    // Get the latest matching version from NPM if a version range is 
specified
    +    return util.getLatestMatchingNpmVersion(packageName, 
packageVersion).then(
    +        function (latestVersion) {
    +            return cachePackage(packageName, latestVersion);
    +        }
    +    );
    +}
    +
    +/**
    + * Invokes "npm cache add," and then returns a promise that resolves to a 
directory containing the downloaded,
    + * or cached package.
    + * @param packageName - name of an npm package
    + * @param packageVersion - requested version (not a version range)
    + */
    +function cachePackage(packageName, packageVersion) {
    +    var cacheDir = path.join(util.libDirectory, 'npm_cache');
    +
    +    // If already cached, use that rather than calling 'npm cache add' 
again.
    +    var packageCacheDir = path.resolve(cacheDir, packageName, 
packageVersion);
    --- End diff --
    
    If `packageVersion` is not provided, this will throw the following error: 
'TypeError: Path must be a string. Received undefined'. IMO while this is 
legitimate error, it probably needs to be wrapped into promise, since this 
function return a promised result.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to