[ 
https://issues.apache.org/jira/browse/CB-11985?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15561759#comment-15561759
 ] 

ASF GitHub Bot commented on CB-11985:
-------------------------------------

Github user TimBarham commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/498#discussion_r82568768
  
    --- Diff: cordova-lib/src/plugman/registry/registry.js ---
    @@ -114,19 +113,11 @@ function initThenLoadSettingsWithRestore(promises) {
     }
     
     /**
    -* @param {Array} with one element - the plugin id or "id@version"
    +* @param {string} plugin - the plugin id or "id@version"
     * @return {Promise.<string>} Promised path to fetched package.
     */
     function fetchPlugin(plugin) {
    -    return initThenLoadSettingsWithRestore(function () {
    -        events.emit('log', 'Fetching plugin "' + plugin + '" via npm');
    -        return Q.ninvoke(npm.commands, 'cache', ['add', plugin])
    -        .then(function (info) {
    -            var unpack = require('../../util/unpack');
    -            var pluginDir = path.resolve(npm.cache, info.name, 
info.version, 'package');
    -            // Unpack the plugin that was added to the cache (CB-8154)
    -            var package_tgz = path.resolve(npm.cache, info.name, 
info.version, 'package.tgz');
    -            return unpack.unpackTgz(package_tgz, pluginDir);
    -        });
    -    });
    +    events.emit('log', 'Fetching plugin "' + plugin + '" via npm');
    +    var pluginSplit = plugin.split('@');
    +    return npmhelper.fetchPackage(pluginSplit[0], pluginSplit[1]);
    --- End diff --
    
    Hah, look at that. I didn't know @riknoll had added support for scoped 
packages. I'll switch this to use `plugin-spec-parser`.


> Cordova hits internet unnecessarily when getting cached platform or plugin
> --------------------------------------------------------------------------
>
>                 Key: CB-11985
>                 URL: https://issues.apache.org/jira/browse/CB-11985
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: CordovaLib
>    Affects Versions: 6.3.1
>            Reporter: Tim Barham
>            Assignee: Tim Barham
>
> In you are disconnected from the internet and try to add a platform or plugin 
> that has previously been cached, Cordova eventually successfully installs the 
> platform/plugin, but only after a very long wait.
> We could check for the existence of the cached platform/plugin before calling 
> {{npm cache add}}. This would mean an instant return when not connected to 
> the internet.
> Note that this will only help if we are adding a specific version - when a 
> version range is specified, we need to hit the internet anyway to find the 
> matching version.
> Background: First time build failures in Cordova tools in Visual Studio are 
> primarily due to {{npm}} failures. Therefore we are working to avoid any 
> requirement for {{npm}}} to hit the internet in simple build scenarios. This 
> includes pre-installing cached versions of certain platforms and plugins. But 
> we only get the full benefit if Cordova uses these cached versions if it 
> finds them, without calling {{npm cache add}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to