You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/09/12 20:14:48 UTC

[20/40] git commit: Fix use for path.join etc. for web paths as opposed to platform paths.

Fix use for path.join etc. for web paths as opposed to platform paths.


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

Branch: refs/heads/ffos
Commit: f276c21dc1e550316d9728361c2202c5a3338610
Parents: 479d339
Author: Braden Shepherdson <br...@gmail.com>
Authored: Tue Sep 3 14:41:46 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Tue Sep 3 14:41:46 2013 -0400

----------------------------------------------------------------------
 src/prepare.js | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/f276c21d/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index aed3f48..7ccb3d0 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -140,10 +140,13 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir) {
     
             allModules.forEach(function(module) {
                 // Copy the plugin's files into the www directory.
-                var dirname = path.dirname(module.attrib.src);
-    
-                var dir = path.join(platformPluginsDir, plugin_id, dirname);
-                shell.mkdir('-p', dir);
+                // NB: We can't always use path.* functions here, because they will use platform slashes.
+                // But the path in the plugin.xml and in the cordova_plugins.js should be always forward slashes.
+                var pathParts = module.attrib.src.split('/');
+
+                var fsDirname = path.join.apply(path, pathParts.slice(0, -1));
+                var fsDir = path.join(platformPluginsDir, plugin_id, fsDirname);
+                shell.mkdir('-p', fsDir);
     
                 // Read in the file, prepend the cordova.define, and write it back out.
                 var moduleName = plugin_id + '.';
@@ -154,16 +157,17 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir) {
                     moduleName += result[1];
                 }
     
-                var scriptContent = fs.readFileSync(path.join(pluginDir, module.attrib.src), 'utf-8');
+                var fsPath = path.join.apply(path, pathParts);
+                var scriptContent = fs.readFileSync(path.join(pluginDir, fsPath), 'utf-8');
                 scriptContent = 'cordova.define("' + moduleName + '", function(require, exports, module) {' + scriptContent + '});\n';
-                fs.writeFileSync(path.join(platformPluginsDir, plugin_id, module.attrib.src), scriptContent, 'utf-8');
+                fs.writeFileSync(path.join(platformPluginsDir, plugin_id, fsPath), scriptContent, 'utf-8');
                 if(platform == 'wp7' || platform == 'wp8' || platform == "windows8") {
-                    wp_csproj.addSourceFile(path.join('www', 'plugins', plugin_id, module.attrib.src));
+                    wp_csproj.addSourceFile(path.join('www', 'plugins', plugin_id, fsPath));
                 }
     
                 // Prepare the object for cordova_plugins.json.
                 var obj = {
-                    file: path.join('plugins', plugin_id, module.attrib.src),
+                    file: ['plugins', plugin_id, module.attrib.src].join('/'),
                     id: moduleName
                 };