cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vladimir-kotikov <...@git.apache.org>
Subject [GitHub] cordova-lib pull request: CB-10986: Adding support for scoped npm ...
Date Tue, 12 Apr 2016 08:33:54 GMT
Github user vladimir-kotikov commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/425#discussion_r59339491
  
    --- Diff: cordova-lib/src/cordova/util.js ---
    @@ -401,3 +407,48 @@ function getAvailableNpmVersions(module_name) {
             });
         });
     }
    +
    +/**
    + * Extracts the name and spec from an npm style package spec that follows the
    + * format of (@scope/)?package(@spec)?
    + * @param {String} raw  The raw npm style package spec
    + * @returns {String[]}  An array containing the package name with optional scope
    + *                      followed by the plugin spec (either value may be null
    + *                      if not matched)
    + */
    +function parseRegistryPluginSpec(raw) {
    +    var split = NPM_SPEC_REGEX.exec(raw);
    +    if (split) {
    +        var package = split[1] ? split[1] + split[2] : split[2];
    +        var version = split[3] || null;
    +        return [package, version];
    +    } else {
    +        return [null, null];
    +    }
    +}
    +
    +/**
    + * Extracts the package name from an npm style package spec of the format
    + * (@scope/)?package(@spec)?. Useful for getting the id used for directories
    + * created for install
    + * @param {String} raw  The raw npm style package spec
    + * @returns {String}    The package name without scope or version or the original
    + *                      string if it isn't an npm package spec
    + */
    +function extractPluginId(raw) {
    +    var split = NPM_SPEC_REGEX.exec(raw);
    +    return split ? split[2] : raw;
    +}
    +
    +
    +/**
    + * Determines if a string is a package spec of the format @scope/package(@spec)?
    + * or not
    + * @param {String} raw  The raw npm style package spec
    + * @returns {boolean}   True if the given string follows the format of an npm style
    + *                      package spec or false otherwise
    + */
    +function isScopedRegistryPluginSpec(raw) {
    --- End diff --
    
    This function might be unnecessary if `parseRegistryPluginSpec` would return a structured
result with e.g. `scope` field, so you can just check if `spec.scope` is defined


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message