Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 67D1A10D0B for ; Wed, 24 Dec 2014 21:22:54 +0000 (UTC) Received: (qmail 93903 invoked by uid 500); 24 Dec 2014 21:22:54 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 93875 invoked by uid 500); 24 Dec 2014 21:22:54 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 93851 invoked by uid 99); 24 Dec 2014 21:22:54 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Dec 2014 21:22:54 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id DEA89A37EE0; Wed, 24 Dec 2014 21:22:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: commits@cordova.apache.org Date: Wed, 24 Dec 2014 21:22:55 -0000 Message-Id: In-Reply-To: <665b95a523b84049a0fd42cac3862bc3@git.apache.org> References: <665b95a523b84049a0fd42cac3862bc3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/3] cordova-lib git commit: CB-8216 Resolve plugin paths relative to original CWD CB-8216 Resolve plugin paths relative to original CWD Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/402d04bf Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/402d04bf Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/402d04bf Branch: refs/heads/master Commit: 402d04bf353095ff2deed353abf41a3515341e38 Parents: 2148d95 Author: Andrew Grieve Authored: Wed Dec 24 16:19:23 2014 -0500 Committer: Andrew Grieve Committed: Wed Dec 24 16:22:33 2014 -0500 ---------------------------------------------------------------------- cordova-lib/src/cordova/util.js | 25 +++++++++++++++++++++++++ cordova-lib/src/plugman/fetch.js | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/402d04bf/cordova-lib/src/cordova/util.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/cordova/util.js b/cordova-lib/src/cordova/util.js index 5992ab9..504bcf5 100644 --- a/cordova-lib/src/cordova/util.js +++ b/cordova-lib/src/cordova/util.js @@ -33,6 +33,8 @@ if (!global_config_path) { global_config_path = path.join(HOME, '.cordova'); } +var origCwd = null; + var lib_path = path.join(global_config_path, 'lib'); shell.mkdir('-p', lib_path); @@ -51,6 +53,8 @@ exports.projectWww = projectWww; exports.projectConfig = projectConfig; exports.preProcessOptions = preProcessOptions; exports.addModuleProperty = addModuleProperty; +exports.getOrigWorkingDirectory = getOrigWorkingDirectory; +exports.fixRelativePath = fixRelativePath; function isRootDir(dir) { if (fs.existsSync(path.join(dir, 'www'))) { @@ -109,10 +113,31 @@ function cdProjectRoot() { if (!projectRoot) { throw new CordovaError('Current working directory is not a Cordova-based project.'); } + if (!origCwd) { + origCwd = process.env.PWD || process.cwd(); + } + process.env.PWD = projectRoot; process.chdir(projectRoot); return projectRoot; } +function getOrigWorkingDirectory() { + return origCwd || process.env.PWD || process.cwd(); +} + +// Fixes up relative paths that are no longer valid due to chdir() within cdProjectRoot(). +function fixRelativePath(value, /* optional */ cwd) { + // Don't touch absolute paths. + if (value[1] == ':' || value[0] == path.sep) { + return value; + } + var newDir = cwd || process.env.PWD || process.cwd(); + var origDir = getOrigWorkingDirectory(); + var pathDiff = path.relative(newDir, origDir); + var ret = path.normalize(path.join(pathDiff, value)); + return ret; +} + // Recursively deletes .svn folders from a target path function deleteSvnFolders(dir) { var contents = fs.readdirSync(dir); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/402d04bf/cordova-lib/src/plugman/fetch.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js index 48bb9b5..2170611 100644 --- a/cordova-lib/src/plugman/fetch.js +++ b/cordova-lib/src/plugman/fetch.js @@ -34,6 +34,7 @@ var shell = require('shelljs'), path = require('path'), Q = require('q'), registry = require('./registry/registry'); +var cordovaUtil = require('../cordova/util'); // Cache of PluginInfo objects for plugins in search path. var localPlugins = null; @@ -102,7 +103,7 @@ function fetchPlugin(plugin_src, plugins_dir, options) { var p, // The Q promise to be returned. linkable = true, - plugin_dir = path.join(plugin_src, options.subdir); + plugin_dir = cordovaUtil.fixRelativePath(path.join(plugin_src, options.subdir)); if (fs.existsSync(plugin_dir)) { p = Q(plugin_dir); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org