You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by na...@apache.org on 2014/10/02 20:17:47 UTC
[13/29] git commit: Use add --compact flag in check_reqs when listing
targets. No functional change.
Use add --compact flag in check_reqs when listing targets. No functional change.
Project: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/commit/9ec000c3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/tree/9ec000c3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/diff/9ec000c3
Branch: refs/heads/master
Commit: 9ec000c3cbd2cbd4d8739ae33f154af23d453763
Parents: d31dbe8
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Sep 10 12:43:40 2014 -0400
Committer: Prabhjot Singh <pr...@amazon.com>
Committed: Wed Sep 17 15:20:31 2014 +0530
----------------------------------------------------------------------
bin/lib/check_reqs.js | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/9ec000c3/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index 6d1dee3..a9ba2eb 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -48,20 +48,21 @@ function tryCommand(cmd, errMsg) {
// Get valid target from framework/project.properties
module.exports.get_target = function() {
- if(fs.existsSync(path.join(ROOT, 'framework', 'project.properties'))) {
- var target = shelljs.grep(/target=android-[\d+]/, path.join(ROOT, 'framework', 'project.properties'));
- return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', '');
- } else if (fs.existsSync(path.join(ROOT, 'project.properties'))) {
- // if no target found, we're probably in a project and project.properties is in ROOT.
- // this is called on the project itself, and can support Google APIs AND Vanilla Android
- var target = shelljs.grep(/target=android-[\d+]/, path.join(ROOT, 'project.properties')) ||
- shelljs.grep(/target=Google Inc.:Google APIs:[\d+]/, path.join(ROOT, 'project.properties'));
- if(target == "" || !target) {
- // Try Google Glass APIs
- target = shelljs.grep(/target=Google Inc.:Glass Development Kit Preview:[\d+]/, path.join(ROOT, 'project.properties'));
+ function extractFromFile(filePath) {
+ var target = shelljs.grep(/\btarget=/, filePath);
+ if (!target) {
+ throw new Error('Could not find android target within: ' + filePath);
}
- return target.split('=')[1].replace('\n', '').replace('\r', '');
+ return target.split('=')[1].trim();
+ }
+ if (fs.existsSync(path.join(ROOT, 'framework', 'project.properties'))) {
+ return extractFromFile(path.join(ROOT, 'framework', 'project.properties'));
+ }
+ if (fs.existsSync(path.join(ROOT, 'project.properties'))) {
+ // if no target found, we're probably in a project and project.properties is in ROOT.
+ return extractFromFile(path.join(ROOT, 'project.properties'));
}
+ throw new Error('Could not find android target. File missing: ' + path.join(ROOT, 'project.properties'));
}
// Returns a promise. Called only by build and clean commands.
@@ -180,13 +181,17 @@ module.exports.check_android = function() {
};
module.exports.check_android_target = function(valid_target) {
+ // valid_target can look like:
+ // android-19
+ // android-L
+ // Google Inc.:Google APIs:20
+ // Google Inc.:Glass Development Kit Preview:20
var msg = 'Failed to run "android". Make sure you have the latest Android SDK installed, and that the "android" command (inside the tools/ folder) is added to your PATH.';
- return tryCommand('android list targets', msg)
+ return tryCommand('android list targets --compact', msg)
.then(function(output) {
- if (!output.match(valid_target)) {
- throw new Error('Please install Android target "' + valid_target + '".\n' +
- output + '\n\n' +
- 'Hint: Install it using the SDK manager by running: ' + forgivingWhichSync('android'));
+ if (output.split('\n').indexOf(valid_target) == -1) {
+ throw new Error('Please install Android target: "' + valid_target + '".\n' +
+ 'Hint: Open the SDK manager by running: ' + forgivingWhichSync('android'));
}
});
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org