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 2013/09/12 04:14:32 UTC

js commit: [CB-4149] Read version from VERSION when there is no .git/

Updated Branches:
  refs/heads/master e2942e162 -> 6140e1683


[CB-4149] Read version from VERSION when there is no .git/


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

Branch: refs/heads/master
Commit: 6140e1683c3df47a698748636c405fed3d2273f4
Parents: e2942e1
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Sep 11 22:13:09 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Sep 11 22:13:09 2013 -0400

----------------------------------------------------------------------
 build/packager.js | 44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6140e168/build/packager.js
----------------------------------------------------------------------
diff --git a/build/packager.js b/build/packager.js
index c154c5c..eaffc15 100644
--- a/build/packager.js
+++ b/build/packager.js
@@ -30,32 +30,36 @@ packager.computeCommitId = function(callback) {
         callback(cachedGitVersion);
         return;
     }
-    var gitPath = 'git';
-    var args = 'describe --tags --long';
-    childProcess.exec(gitPath + ' ' + args, function(err, stdout, stderr) {
-        var isWindows = process.platform.slice(0, 3) == 'win';
-        if (err && isWindows) {
-            gitPath = '"' + path.join(process.env['ProgramFiles'], 'Git', 'bin', 'git.exe') + '"';
-            childProcess.exec(gitPath + ' ' + args, function(err, stdout, stderr) {
-                if (err) {
-                    error(err);
-                } else {
-                    done(stdout);
-                }
-            });
-        } else if (err) {
-            error(err);
-        } else {
-            done(stdout);
-        }
-    });
+    if (fs.existsSync('.git')) {
+        var gitPath = 'git';
+        var args = 'describe --tags --long';
+        childProcess.exec(gitPath + ' ' + args, function(err, stdout, stderr) {
+            var isWindows = process.platform.slice(0, 3) == 'win';
+            if (err && isWindows) {
+                gitPath = '"' + path.join(process.env['ProgramFiles'], 'Git', 'bin', 'git.exe') + '"';
+                childProcess.exec(gitPath + ' ' + args, function(err, stdout, stderr) {
+                    if (err) {
+                        error(err);
+                    } else {
+                        done(stdout);
+                    }
+                });
+            } else if (err) {
+                error(err);
+            } else {
+                done(stdout);
+            }
+        });
+    } else {
+        done(fs.readFileSync('VERSION', { encoding: 'utf8' }));
+    }
 
     function error(err) {
         throw new Error(err);
     }
 
     function done(stdout) {
-        var version = stdout.trim().replace(/^2.5.0-.*?-/, 'dev-');
+        var version = stdout.trim();
         cachedGitVersion = version;
         callback(version);
     };