cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [1/2] git commit: Enforse working directory to be sibling of cordova-coho
Date Thu, 24 Apr 2014 19:17:18 GMT
Repository: cordova-coho
Updated Branches:
  refs/heads/master 608e06d93 -> b8f3a0f98


Enforse working directory to be sibling of cordova-coho


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

Branch: refs/heads/master
Commit: 73630d295919d6ddc10aa25758450518151943c5
Parents: 608e06d
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Thu Apr 24 14:05:09 2014 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Thu Apr 24 14:05:09 2014 -0400

----------------------------------------------------------------------
 src/apputil.js | 12 +++++++++++-
 src/main.js    |  8 ++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/73630d29/src/apputil.js
----------------------------------------------------------------------
diff --git a/src/apputil.js b/src/apputil.js
index ec158a4..2c6d492 100644
--- a/src/apputil.js
+++ b/src/apputil.js
@@ -21,6 +21,16 @@ var path = require('path');
 
 var origWorkingDir = process.cwd();
 
+exports.initWorkingDir = function() {
+    var curDir = path.resolve(origWorkingDir);
+    var newDir = path.resolve(path.join(__dirname), '..', '..');
+    if (curDir != newDir) {
+        console.log('Running from ' + newDir);
+        process.chdir(newDir);
+        origWorkingDir = newDir;
+    }
+}
+
 exports.fatal = function() {
     console.error.apply(console, arguments);
     process.exit(1);
@@ -31,7 +41,7 @@ exports.print = function() {
     // Prefix any prints() to distinguish them from command output.
     if (newArgs.length > 1 || newArgs[0]) {
         var curDir = path.relative(origWorkingDir, process.cwd());
-        var prefix = curDir ? './' + curDir + '/ =' : './ =';
+        var prefix = curDir ? curDir + '/ =' : './ =';
         var PREFIX_LEN = 30;
         if (prefix.length < PREFIX_LEN) {
             prefix += new Array(PREFIX_LEN - prefix.length + 1).join('=');

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/73630d29/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index 4b3f4db..f69c37a 100644
--- a/src/main.js
+++ b/src/main.js
@@ -17,6 +17,7 @@ specific language governing permissions and limitations
 under the License.
 */
 
+var path = require('path');
 try {
     var co = require('co');
     var optimist = require('optimist');
@@ -24,6 +25,7 @@ try {
     console.log('Please run "npm install" from this directory:\n\t' + __dirname);
     process.exit(2);
 }
+var apputil = require('./apputil');
 
 module.exports = function() {
     var repoCommands = [
@@ -131,6 +133,9 @@ module.exports = function() {
         .usage(usage)
         .check(function(argv) {
             command = argv._[0];
+            if (command == 'foreach') {
+                argv._[0] = command = 'for-each';
+            }
             if (!command) {
                 throw 'No command specified.';
             }
@@ -139,6 +144,9 @@ module.exports = function() {
             }
         }).argv;
 
+    // Change directory to be a sibling of coho.
+    apputil.initWorkingDir();
+
     var entry = commandMap[command].entryPoint;
     co(entry)();
 }


Mime
View raw message