You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/01/24 16:40:49 UTC

android commit: CB-5889 Make update script find project name instead of using "null" for CordovaLib

Updated Branches:
  refs/heads/master 94934ae2c -> cc94cc7d0


CB-5889 Make update script find project name instead of using "null" for CordovaLib


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

Branch: refs/heads/master
Commit: cc94cc7d01c90f3a7e4a78cc5bf065f7323c6d2c
Parents: 94934ae
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Jan 24 10:40:09 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Jan 24 10:40:40 2014 -0500

----------------------------------------------------------------------
 bin/lib/create.js | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/cc94cc7d/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index b2321bd..8025a0b 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -202,18 +202,29 @@ exports.createProject = function(project_path, package_name, project_name, proje
 
 // Attribute removed in Cordova 4.4 (CB-5447).
 function removeDebuggableFromManifest(projectPath) {
-    var manifestPath   = path.join(projectPath, 'AndroidManifest.xml');
+    var manifestPath = path.join(projectPath, 'AndroidManifest.xml');
     shell.sed('-i', /\s*android:debuggable="true"/, '', manifestPath);
 }
 
+function extractProjectNameFromManifest(projectPath) {
+    var manifestPath = path.join(projectPath, 'AndroidManifest.xml');
+    var manifestData = fs.readFileSync(manifestPath, 'utf8');
+    var m = /<activity[\s\S]*?android:name\s*=\s*"(.*?)"/i.exec(manifestData);
+    if (!m) {
+      throw new Error('Could not find activity name in ' + manifestPath);
+    }
+    return m[1];
+}
+
 // Returns a promise.
 exports.updateProject = function(projectPath) {
     var version = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim();
     // Check that requirements are met and proper targets are installed
     return check_reqs.run()
     .then(function() {
+        var projectName = extractProjectNameFromManifest(projectPath);
         var target_api = check_reqs.get_target();
-        copyJsAndLibrary(projectPath, false, null);
+        copyJsAndLibrary(projectPath, false, projectName);
         copyScripts(projectPath);
         copyAntRules(projectPath);
         removeDebuggableFromManifest(projectPath);