cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject git commit: CB-4871 Use npmconf instead of npm as a dependency in CLI
Date Thu, 09 Jan 2014 19:55:01 GMT
Updated Branches:
  refs/heads/master 5702798f1 -> c6a3872ab


CB-4871 Use npmconf instead of npm as a dependency in CLI


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/c6a3872a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/c6a3872a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/c6a3872a

Branch: refs/heads/master
Commit: c6a3872ab08240cfb3789acc4991d8561bfc5715
Parents: 5702798
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Thu Jan 9 14:54:38 2014 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Thu Jan 9 14:54:38 2014 -0500

----------------------------------------------------------------------
 package.json           |  2 +-
 spec/lazy_load.spec.js | 11 ++++++-----
 src/lazy_load.js       |  8 ++++----
 3 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c6a3872a/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 00f0bf0..78d5c6b 100644
--- a/package.json
+++ b/package.json
@@ -36,7 +36,7 @@
     "request": "2.22.0",
     "semver": "1.1.0",
     "tar": "0.1.x",
-    "npm": "1.3.x",
+    "npmconf": "0.1.x",
     "q": "~0.9",
     "optimist": "0.6.0",
     "mime": "~1.2.11",

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c6a3872a/spec/lazy_load.spec.js
----------------------------------------------------------------------
diff --git a/spec/lazy_load.spec.js b/spec/lazy_load.spec.js
index c144e6d..61b857a 100644
--- a/spec/lazy_load.spec.js
+++ b/spec/lazy_load.spec.js
@@ -20,7 +20,7 @@ var lazy_load = require('../src/lazy_load'),
     config = require('../src/config'),
     util = require('../src/util'),
     shell = require('shelljs'),
-    npm = require('npm');
+    npmconf = require('npmconf');
     path = require('path'),
     hooker = require('../src/hooker'),
     request = require('request'),
@@ -83,6 +83,7 @@ describe('lazy_load module', function() {
         });
 
         describe('remote URLs for libraries', function() {
+            var npmConfProxy;
             var req,
                 load_spy,
                 events = {},
@@ -94,6 +95,7 @@ describe('lazy_load module', function() {
                     pipe: jasmine.createSpy().andCallFake(function() { return fakeRequest;
})
                 };
             beforeEach(function() {
+                npmConfProxy = null;
                 events = {};
                 fakeRequest.on.reset();
                 fakeRequest.pipe.reset();
@@ -104,8 +106,7 @@ describe('lazy_load module', function() {
                     }, 10);
                     return fakeRequest;
                 });
-                load_spy = spyOn(npm, 'load').andCallFake(function(cb) { cb(); });
-                npm.config.get = function() { return null; };
+                load_spy = spyOn(npmconf, 'load').andCallFake(function(cb) { cb(null, { get:
function() { return npmConfProxy }}); });
             });
 
             it('should call request with appopriate url params', function(done) {
@@ -120,7 +121,7 @@ describe('lazy_load module', function() {
             });
             it('should take into account https-proxy npm configuration var if exists for
https:// calls', function(done) {
                 var proxy = 'https://somelocalproxy.com';
-                npm.config.get = function() { return proxy; };
+                npmConfProxy = proxy;
                 var url = 'https://github.com/apache/someplugin';
                 lazy_load.custom(url, 'random', 'android', '1.0').then(function() {
                     expect(req).toHaveBeenCalledWith({
@@ -133,7 +134,7 @@ describe('lazy_load module', function() {
             });
             it('should take into account proxy npm config var if exists for http:// calls',
function(done) {
                 var proxy = 'http://somelocalproxy.com';
-                npm.config.get = function() { return proxy; };
+                npmConfProxy = proxy;
                 var url = 'http://github.com/apache/someplugin';
                 lazy_load.custom(url, 'random', 'android', '1.0').then(function() {
                     expect(req).toHaveBeenCalledWith({

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c6a3872a/src/lazy_load.js
----------------------------------------------------------------------
diff --git a/src/lazy_load.js b/src/lazy_load.js
index c54d4b7..3ca43f1 100644
--- a/src/lazy_load.js
+++ b/src/lazy_load.js
@@ -20,7 +20,7 @@ var path          = require('path'),
     fs            = require('fs'),
     shell         = require('shelljs'),
     platforms     = require('../platforms'),
-    npm           = require('npm'),
+    npmconf       = require('npmconf'),
     events        = require('./events'),
     request       = require('request'),
     config        = require('./config'),
@@ -69,13 +69,13 @@ module.exports = {
         }).then(function() {
             var uri = URL.parse(url);
             var d = Q.defer();
-            npm.load(function() {
+            npmconf.load(function(err, conf) {
                 // Check if NPM proxy settings are set. If so, include them in the request()
call.
                 var proxy;
                 if (uri.protocol == 'https:') {
-                    proxy = npm.config.get('https-proxy');
+                    proxy = conf.get('https-proxy');
                 } else if (uri.protocol == 'http:') {
-                    proxy = npm.config.get('proxy');
+                    proxy = conf.get('proxy');
                 }
 
                 shell.mkdir('-p', download_dir);


Mime
View raw message