You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2015/05/06 10:16:37 UTC

cordova-lib git commit: CB-8898 Introduces `requirements` cordova module

Repository: cordova-lib
Updated Branches:
  refs/heads/master a82fe9c46 -> d6f2b1141


CB-8898 Introduces `requirements` cordova module


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

Branch: refs/heads/master
Commit: d6f2b11412f323557f950a92fa4c24ae4443bbf5
Parents: a82fe9c
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Thu Apr 23 10:56:53 2015 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Wed May 6 09:01:30 2015 +0300

----------------------------------------------------------------------
 cordova-lib/src/cordova/cordova.js      |  1 +
 cordova-lib/src/cordova/requirements.js | 68 ++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d6f2b114/cordova-lib/src/cordova/cordova.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/cordova.js b/cordova-lib/src/cordova/cordova.js
index d66a8b1..dd71b39 100644
--- a/cordova-lib/src/cordova/cordova.js
+++ b/cordova-lib/src/cordova/cordova.js
@@ -68,6 +68,7 @@ addModuleProperty(module, 'compile', './compile', true);
 addModuleProperty(module, 'run', './run', true);
 addModuleProperty(module, 'info', './info', true);
 addModuleProperty(module, 'targets', './targets', true);
+addModuleProperty(module, 'requirements', './requirements', true);
 addModuleProperty(module, 'projectMetadata', './project_metadata', true);
 
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d6f2b114/cordova-lib/src/cordova/requirements.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/requirements.js b/cordova-lib/src/cordova/requirements.js
new file mode 100644
index 0000000..dfa150c
--- /dev/null
+++ b/cordova-lib/src/cordova/requirements.js
@@ -0,0 +1,68 @@
+/**
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+*/
+
+var cordova_util = require('./util');
+var events       = require('../events');
+var path         = require('path');
+var Q            = require('q');
+var CordovaError = require('../CordovaError');
+
+/**
+ * Runs requirements check against platforms specified in 'platfoms' argument
+ *
+ * @param  {String[]} platforms List of platforms for requirements check. If none, all
+ *                                      platforms, added to project will be checked
+ *
+ * @return {Promise}            Promise fullfilled with map of platforms and requirements
+ *                                      check results for each platform
+ */
+module.exports = function check_reqs(platforms) {
+    var projectRoot = cordova_util.isCordova();
+    var platformsDir = path.join(projectRoot, 'platforms');
+    platforms = cordova_util.preProcessOptions(platforms).platforms;
+
+    var platformChecks = platforms.map(function (platform) {
+        var modulePath = path.join(platformsDir, platform, 'cordova', 'lib', 'check_reqs');
+        try {
+            events.emit('verbose', 'Checking requirements for ' + platform + ' platform');
+            return require(modulePath).check_all();
+        } catch (e) {
+            var errorMsg = 'Failed to check requirements for ' + platform + ' platform. ' +
+                'check_reqs module is missing for platfrom. Skipping it...';
+            return Q.reject(errorMsg);
+        }
+    });
+
+    var checks = {};
+
+    return Q.allSettled(platformChecks)
+    .then(function (settledChecks) {
+
+        settledChecks.forEach(function (settledCheck, idx) {
+            var platformName = platforms[idx];
+            var result  = settledCheck.state === 'fulfilled' ?
+                settledCheck.value :
+                new CordovaError(settledCheck.reason);
+
+            checks[platformName] = result;
+        });
+
+        return checks;
+    });
+};


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