cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [09/50] [abbrv] cordova-lib git commit: CB-12001: fixed failing test
Date Thu, 09 Mar 2017 20:39:12 GMT
CB-12001: fixed failing test


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

Branch: refs/heads/common-2.0.x
Commit: d7a1487a422452a74ce0efe4f5222431ca7c0fed
Parents: ed9ba79
Author: Steve Gill <stevengill97@gmail.com>
Authored: Tue Nov 22 12:07:15 2016 -0800
Committer: Audrey So <audreyso@apache.org>
Committed: Thu Jan 26 17:36:52 2017 -0800

----------------------------------------------------------------------
 .../spec-cordova/pkgJson-restore.spec.js        | 34 ++++++++++----------
 cordova-lib/src/cordova/platform.js             |  7 ++--
 2 files changed, 22 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d7a1487a/cordova-lib/spec-cordova/pkgJson-restore.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/pkgJson-restore.spec.js b/cordova-lib/spec-cordova/pkgJson-restore.spec.js
index 2b65077..4d5dfec 100644
--- a/cordova-lib/spec-cordova/pkgJson-restore.spec.js
+++ b/cordova-lib/spec-cordova/pkgJson-restore.spec.js
@@ -30,7 +30,7 @@ var helpers = require('./helpers'),
 
 // Use basePkgJson
 describe('tests platform/spec restore with --save', function () {
-    var tmpDir = helpers.tmpDir('platform_test_pkgjson');
+    var tmpDir = helpers.tmpDir('platform_test_pkgjson2');
     var project = path.join(tmpDir, 'project');
     var results;
 
@@ -343,14 +343,14 @@ describe('tests platform/spec restore with --save', function () {
         var platformsFolderPath = path.join(cwd,'platforms/platforms.json');
         var platformsJson;
         var configXmlPath = path.join(cwd, 'config.xml');
-        var androidPlatform = 'android';
+        var bPlatform = 'browser';
         var engines;
         var engNames;
         var engSpec;
 
         emptyPlatformList().then(function() {
             // Add platform with save and fetch
-            return cordova.raw.platform('add', 'https://github.com/apache/cordova-android',
{'save':true, 'fetch':true});
+            return cordova.raw.platform('add', 'https://github.com/apache/cordova-browser',
{'save':true, 'fetch':true});
         }).then(function() {
             // Check that platform was added to config.xml successfully.
             var cfg = new ConfigParser(configXmlPath);
@@ -361,30 +361,30 @@ describe('tests platform/spec restore with --save', function () {
             engSpec = engines.map(function(elem) {
                 return elem.spec;
             });
-            expect(engNames).toEqual([ androidPlatform]);
-            expect(engSpec).toEqual([ 'https://github.com/apache/cordova-android' ]);
+            expect(engNames).toEqual([bPlatform]);
+            expect(engSpec).toEqual([ 'https://github.com/apache/cordova-browser' ]);
             // Check that platform was added to pkg.json successfully.
             delete require.cache[require.resolve(pkgJsonPath)];
             pkgJson = require(pkgJsonPath);
-            expect(pkgJson.cordova.platforms.indexOf('android')).toBeDefined();
-            expect(pkgJson.dependencies['cordova-android']).toEqual('git+https://github.com/apache/cordova-android.git');
+            expect(pkgJson.cordova.platforms.indexOf('browser')).toBeDefined();
+            expect(pkgJson.dependencies['cordova-browser']).toEqual('git+https://github.com/apache/cordova-browser.git');
             // Check that platform was added to platforms list successfully.
             delete require.cache[require.resolve(platformsFolderPath)];
             platformsJson = require(platformsFolderPath);
-            expect(platformsJson[androidPlatform]).toBeDefined();
+            expect(platformsJson[bPlatform]).toBeDefined();
         }).then(function() {
             // Remove platform without --save.
-            return cordova.raw.platform('rm', androidPlatform, {'fetch':true});
+            return cordova.raw.platform('rm', bPlatform, {'fetch':true});
         }).then(function() {
             // Platform in pkg.json should still be there.
             delete require.cache[require.resolve(pkgJsonPath)];
             pkgJson = require(pkgJsonPath);
-            expect(pkgJson.cordova.platforms.indexOf('android')).toBeDefined();
-            expect(pkgJson.dependencies['cordova-android']).toEqual('git+https://github.com/apache/cordova-android.git');
+            expect(pkgJson.cordova.platforms.indexOf('browser')).toBeDefined();
+            expect(pkgJson.dependencies['cordova-browser']).toEqual('git+https://github.com/apache/cordova-browser.git');
             // Platform in platforms.json should not be there.
             delete require.cache[require.resolve(platformsFolderPath)];
             platformsJson = require(platformsFolderPath);
-            expect(platformsJson[androidPlatform]).toBeUndefined();
+            expect(platformsJson[bPlatform]).toBeUndefined();
         }).then(function() {
             // Run cordova prepare
             return cordova.raw.prepare({'fetch':true});
@@ -398,17 +398,17 @@ describe('tests platform/spec restore with --save', function () {
             engSpec = engines.map(function(elem) {
                 return elem.spec;
             });
-            expect(engNames).toEqual([ 'android' ]);
-            expect(engSpec).toEqual([ 'git+https://github.com/apache/cordova-android.git'
]);
+            expect(engNames).toEqual([ 'browser' ]);
+            expect(engSpec).toEqual([ 'git+https://github.com/apache/cordova-browser.git'
]);
             // No change to pkg.json.
             delete require.cache[require.resolve(pkgJsonPath)];
             pkgJson = require(pkgJsonPath);
-            expect(pkgJson.cordova.platforms.indexOf('android')).toBeDefined();
-            expect(pkgJson.dependencies['cordova-android']).toEqual('git+https://github.com/apache/cordova-android.git');
+            expect(pkgJson.cordova.platforms.indexOf('browser')).toBeDefined();
+            expect(pkgJson.dependencies['cordova-browser']).toEqual('git+https://github.com/apache/cordova-browser.git');
             // Check that platform was restored to platform.json list successfully.
             delete require.cache[require.resolve(platformsFolderPath)];
             platformsJson = require(platformsFolderPath);
-            expect(platformsJson[androidPlatform]).toBeDefined();
+            expect(platformsJson[bPlatform]).toBeDefined();
         }).fail(function(err) {
             expect(err).toBeUndefined();
         }).fin(done);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d7a1487a/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index e395835..c529632 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -180,6 +180,7 @@ function addHelper(cmd, hooksRunner, projectRoot, targets, opts) {
                     // basically a valid NodeJS script but intended to be used as a regular
                     // executable script.
                     if (path.basename(apiEntryPoint) === 'Api.js') {
+                        delete require.cache[apiEntryPoint];
                         PlatformApi = require(apiEntryPoint);
                         events.emit('verbose', 'PlatformApi successfully found for platform
' + platform);
                     }
@@ -324,7 +325,6 @@ function downloadPlatform(projectRoot, platform, version, opts) {
             if(!platform) {
                 target = version;
             }
-
             events.emit('log', 'Using cordova-fetch for '+ target);
             return fetch(target, projectRoot, opts);
         }
@@ -369,7 +369,10 @@ function getPlatformDetailsFromDir(dir, platformIfKnown){
     var version;
 
     try {
-        var pkg = require(path.join(libDir, 'package'));
+        var pkgPath = path.join(libDir, 'package.json');
+        delete require.cache[pkgPath];
+        var pkg = require(pkgPath);
+
         platform = platformFromName(pkg.name);
         version = pkg.version;
     } catch(e) {


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


Mime
View raw message