cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [2/2] git commit: don't fail on undetected cordova version
Date Tue, 04 Jun 2013 20:26:33 GMT
don't fail on undetected cordova version


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

Branch: refs/heads/master
Commit: eb68e29ff8ee37ec0f4de58fee4d953e7e38235f
Parents: 8c9783a
Author: Brett Rudd <brettrudd@gmail.com>
Authored: Wed May 29 15:22:49 2013 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Tue Jun 4 13:26:09 2013 -0700

----------------------------------------------------------------------
 src/install.js |   61 ++++++++++++++++++++++++++++----------------------
 1 files changed, 34 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/eb68e29f/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index ba9746f..f25f907 100644
--- a/src/install.js
+++ b/src/install.js
@@ -75,36 +75,43 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir,
opt
     
     // checking engine 
     // will there be a case for multiple engine support?
-    var engines = plugin_et.findall('engines/engine');
-    engines.forEach(function(engine){
-        if(engine.attrib["name"].toLowerCase() === "cordova"){
-            var engineVersion = engine.attrib["version"];
-            var versionPath = path.join(project_dir, 'cordova', 'version');
-            
-            // need to rethink this so I don't have to chmod anything
-            fs.chmodSync(versionPath, '755');
-            
-            var versionScript = shell.exec(versionPath, {silent: true});
-            if(versionScript.code>0){
-                var err = new Error('File missing: ' + versionPath);
-                if (callback) callback(err);
-                else throw err;           
-            }else{
-                // clean only versionScript.output since semver.clean strips out 
-                // the gt and lt operators
-                if(semver.satisfies(semver.clean(versionScript.output), engineVersion)){
-                    // engine ok!
-                    
+    
+    var versionPath = path.join(project_dir, 'cordova', 'version');
+    if (fs.existsSync(versionPath)) {
+        
+        // need to rethink this so I don't have to chmod anything
+        fs.chmodSync(versionPath, '755');
+        var versionScript = shell.exec(versionPath, {silent: true});
+        
+        var engines = plugin_et.findall('engines/engine');
+        engines.forEach(function(engine){
+            if(engine.attrib["name"].toLowerCase() === "cordova"){
+                var engineVersion = engine.attrib["version"];
+                if(versionScript.code>0){
+                    var err = new Error('File missing: ' + versionPath);
+                    if (callback) callback(err);
+                    else throw err;
                 }else{
-                    var err = new Error('Plugin doesn\'t support Cordova version. Check plugin.xml');
-                if (callback) callback(err);
-                    else throw err; 
+                    // clean only versionScript.output since semver.clean strips out 
+                    // the gt and lt operators
+                    if(semver.satisfies(semver.clean(versionScript.output), engineVersion)){
+                        // engine ok!
+                    
+                    }else{
+                        var err = new Error('Plugin doesn\'t support Cordova version. Check
plugin.xml');
+                    if (callback) callback(err);
+                        else throw err; 
+                    }
                 }
+            } else {
+                // check for other engines?
             }
-        }else{
-            // check for other engines?
-        }
-    });
+        });
+    } 
+    else
+    {
+        console.log('Warning: cordova version not detected. installing anyway.');
+    }
 
     // checking preferences, if certain variables are not provided, we should throw.
     prefs = plugin_et.findall('./preference') || [];


Mime
View raw message