incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [15/78] [abbrv] git commit: On pluginstall, copy in plugin www assets into common project www.
Date Fri, 27 Jul 2012 00:29:15 GMT
On pluginstall, copy in plugin www assets into common project www.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/650af9f6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/650af9f6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/650af9f6

Branch: refs/heads/cordova-client
Commit: 650af9f6f4bb86bc83aebdfb218f4b26ee222b3e
Parents: 9f966c2
Author: Fil Maj <maj.fil@gmail.com>
Authored: Thu Jul 19 13:33:38 2012 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Thu Jul 19 13:33:38 2012 -0700

----------------------------------------------------------------------
 README.md     |    2 ++
 src/plugin.js |   21 ++++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/650af9f6/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 3e6883f..23cdfe2 100644
--- a/README.md
+++ b/README.md
@@ -138,6 +138,8 @@ start cloning any necessary Cordova libraries (which may take a while).
 
 ## TO-DO
 
+- fix pluginstall for ios 2.0
+- interpolating proper app name and shit from config.xml
 - `grep` through this project for 'TODO'
 - blackberry support
 - moar tests

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/650af9f6/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index f5acc4b..8e77d3b 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -1,6 +1,7 @@
 var cordova_util = require('./util'),
     util = require('util'),
     wrench = require('wrench'),
+    cpr = wrench.copyDirSyncRecursive,
     fs = require('fs'),
     path = require('path'),
     config_parser = require('./config_parser'),
@@ -17,6 +18,7 @@ module.exports = function plugin(command, target) {
 
     // Grab config info for the project
     var xml = path.join(projectRoot, 'www', 'config.xml');
+    var projectWww = path.join(projectRoot, 'www');
     var cfg = new config_parser(xml);
     var platforms = cfg.ls_platforms();
 
@@ -48,7 +50,7 @@ module.exports = function plugin(command, target) {
             // Iterate over all platforms in the project and install the
             // plugin.
             var cli = path.join(__dirname, '..', 'node_modules', 'pluginstall', 'cli.js');
-            platforms.map(function(platform) {
+            platforms.forEach(function(platform) {
                 var cmd = util.format('%s %s "%s" "%s"', cli, platform, path.join(projectRoot,
'platforms', platform), target);
                 exec(cmd, function(err, stderr, stdout) {
                     if (err) {
@@ -57,6 +59,23 @@ module.exports = function plugin(command, target) {
                     }
                 });
             });
+            
+            // Add the plugin web assets to the www folder as well
+            // TODO: assumption that web assets go under www folder
+            // inside plugin dir; instead should read plugin.xml
+            var pluginWww = path.join(target, 'www');
+            var wwwContents = ls(pluginWww);
+            wwwContents.forEach(function(asset) {
+                asset = path.resolve(path.join(pluginWww, asset));
+                var info = fs.lstatSync(asset);
+                var name = asset.substr(asset.lastIndexOf('/')+1);
+                var wwwPath = path.join(projectWww, name);
+                if (info.isDirectory()) {
+                    cpr(asset, wwwPath);
+                } else {
+                    fs.writeFileSync(wwwPath, fs.readFileSync(asset));
+                }
+            });
 
             break;
         case 'remove':


Mime
View raw message