You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ka...@apache.org on 2014/11/04 02:19:46 UTC
git commit: Fix forEachRepo for nested calls
Repository: cordova-coho
Updated Branches:
refs/heads/master a3ccf8c48 -> d1d21b7f1
Fix forEachRepo for nested calls
`coho repo-reset -r tools`
Was failing with the following error:
cd: no such file or directory: ../cordova-lib/cordova-lib
Exposed the base working dir from apputil via
apputil.getBaseDir()
Project: http://git-wip-us.apache.org/repos/asf/cordova-coho/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-coho/commit/d1d21b7f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/d1d21b7f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/d1d21b7f
Branch: refs/heads/master
Commit: d1d21b7f1ca7e1bfaf30b9195d55d7f615acefe7
Parents: a3ccf8c
Author: Mark Koudritsky <ka...@gmail.com>
Authored: Mon Nov 3 20:16:19 2014 -0500
Committer: Mark Koudritsky <ka...@gmail.com>
Committed: Mon Nov 3 20:16:19 2014 -0500
----------------------------------------------------------------------
src/apputil.js | 13 ++++++++-----
src/repoutil.js | 19 ++++++++++++++++---
2 files changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/d1d21b7f/src/apputil.js
----------------------------------------------------------------------
diff --git a/src/apputil.js b/src/apputil.js
index dc640e6..e617c15 100644
--- a/src/apputil.js
+++ b/src/apputil.js
@@ -20,7 +20,7 @@ under the License.
var path = require('path');
var chalk = require('chalk');
-var origWorkingDir = process.cwd();
+var origWorkingDir = path.resolve(process.cwd());
var baseWorkingDir = origWorkingDir;
exports.resolveUserSpecifiedPath = function(p) {
@@ -28,13 +28,16 @@ exports.resolveUserSpecifiedPath = function(p) {
};
exports.initWorkingDir = function(chdir) {
- var curDir = path.resolve(origWorkingDir);
- var newDir = chdir ? path.resolve(path.join(__dirname), '..', '..') : curDir;
- if (curDir != newDir) {
+ if(chdir) {
+ var newDir = path.resolve(__dirname, '..', '..');
process.chdir(newDir);
baseWorkingDir = newDir;
}
- console.log('Running from ' + newDir);
+ console.log('Running from ' + baseWorkingDir);
+}
+
+exports.getBaseDir = function() {
+ return baseWorkingDir;
}
exports.fatal = function() {
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/d1d21b7f/src/repoutil.js
----------------------------------------------------------------------
diff --git a/src/repoutil.js b/src/repoutil.js
index 7a9e972..f40e5dd 100644
--- a/src/repoutil.js
+++ b/src/repoutil.js
@@ -458,16 +458,19 @@ exports.forEachRepo = function*(repos, func) {
for (var i = 0; i < repos.length; ++i) {
var repo = repos[i];
var origPath = isInForEachRepoFunction ? process.cwd() : '..';
- var newPath = isInForEachRepoFunction ? path.join('..', repo.repoName) : repo.repoName;
+ // The crazy dance with isInForEachRepoFunction and origPath is needed
+ // for nested forEachRepo calls to work. E.g repo-reset calls
+ // repo-update([oneRepo]) internally.
+ // TODO: rely less on process.cwd()
isInForEachRepoFunction = true;
//cordova-lib lives inside of a top level cordova-lib directory
if(repo.id === 'lib'){
- newPath = newPath + '/cordova-lib';
origPath = origPath + '/..';
}
- shelljs.cd(newPath);
+ var repoDir = getRepoDir(repo);
+ shelljs.cd(repoDir);
if (shelljs.error()) {
apputil.fatal('Repo directory does not exist: ' + repo.repoName + '. First run coho repo-clone.');
@@ -480,3 +483,13 @@ exports.forEachRepo = function*(repos, func) {
}
}
+
+function getRepoDir(repo) {
+ var baseWorkingDir = apputil.getBaseDir();
+ var repoDir = path.join(baseWorkingDir, repo.repoName);
+ if(repo.id === 'lib'){
+ repoDir = path.join(repoDir, 'cordova-lib');
+ }
+ return repoDir;
+}
+exports.getRepoDir = getRepoDir;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org