cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject git commit: CB-5647 Move <assets> copying from install to prepare
Date Thu, 27 Feb 2014 01:39:25 GMT
Repository: cordova-plugman
Updated Branches:
  refs/heads/master 6612a7c72 -> ddc20aaf1


CB-5647 Move <assets> copying from install to prepare

This is for cordova-cli to remove .staging.
GitHub: close #53


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

Branch: refs/heads/master
Commit: ddc20aaf127407a5f6fd3cfe7b6c7507bffaf782
Parents: 6612a7c
Author: Mark Koudritsky <kamrik@chromium.org>
Authored: Wed Feb 26 12:24:14 2014 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Wed Feb 26 20:37:33 2014 -0500

----------------------------------------------------------------------
 spec/install.spec.js           |  2 +-
 spec/platforms/android.spec.js |  6 ++--
 spec/platforms/common.spec.js  | 56 +++++++++++++++++--------------------
 spec/prepare.spec.js           | 13 ++++++---
 src/install.js                 | 38 +++++++++++--------------
 src/platforms/android.js       |  2 ++
 src/platforms/blackberry10.js  |  2 ++
 src/platforms/common.js        | 11 +++-----
 src/platforms/windows8.js      |  7 +++--
 src/platforms/wp7.js           |  5 +++-
 src/platforms/wp8.js           |  7 +++--
 src/prepare.js                 | 41 +++++++++++++++++----------
 src/uninstall.js               |  5 ++--
 13 files changed, 107 insertions(+), 88 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/spec/install.spec.js
----------------------------------------------------------------------
diff --git a/spec/install.spec.js b/spec/install.spec.js
index 555c803..8228660 100644
--- a/spec/install.spec.js
+++ b/spec/install.spec.js
@@ -190,7 +190,7 @@ describe('install', function() {
             });
             waitsFor(function() { return done; }, 'install promise never resolved', 500);
             runs(function() {
-                expect(actions_push.calls.length).toEqual(5);
+                expect(actions_push.calls.length).toEqual(3);
                 expect(c_a).toHaveBeenCalledWith(jasmine.any(Function), [jasmine.any(Object),
path.join(plugins_dir, dummyplugin), temp, dummy_id], jasmine.any(Function), [jasmine.any(Object),
temp, dummy_id]);
                 expect(proc).toHaveBeenCalled();
             });

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/spec/platforms/android.spec.js
----------------------------------------------------------------------
diff --git a/spec/platforms/android.spec.js b/spec/platforms/android.spec.js
index c796592..57f45fe 100644
--- a/spec/platforms/android.spec.js
+++ b/spec/platforms/android.spec.js
@@ -91,13 +91,13 @@ describe('android project handler', function() {
             it('should copy stuff from one location to another by calling common.copyFile',
function() {
                 var source = copyArray(valid_source);
                 var s = spyOn(common, 'copyFile');
-                android['source-file'].install(source[0], dummyplugin, temp); 
+                android['source-file'].install(source[0], dummyplugin, temp);
                 expect(s).toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin.java',
temp, path.join('src', 'com', 'phonegap', 'plugins', 'dummyplugin', 'DummyPlugin.java'));
             });
             it('should throw if source file cannot be found', function() {
                 var source = copyArray(invalid_source);
                 expect(function() {
-                    android['source-file'].install(source[0], faultyplugin, temp); 
+                    android['source-file'].install(source[0], faultyplugin, temp);
                 }).toThrow('"' + path.resolve(faultyplugin, 'src/android/NotHere.java') +
'" not found!');
             });
             it('should throw if target file already exists', function() {
@@ -109,7 +109,7 @@ describe('android project handler', function() {
 
                 var source = copyArray(valid_source);
                 expect(function() {
-                    android['source-file'].install(source[0], dummyplugin, temp); 
+                    android['source-file'].install(source[0], dummyplugin, temp);
                 }).toThrow('"' + target + '" already exists!');
             });
         });

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/spec/platforms/common.spec.js
----------------------------------------------------------------------
diff --git a/spec/platforms/common.spec.js b/spec/platforms/common.spec.js
index 337d9b4..beb646b 100644
--- a/spec/platforms/common.spec.js
+++ b/spec/platforms/common.spec.js
@@ -20,7 +20,7 @@ var common = require('../../src/platforms/common')
   , fs = require('fs')
   , osenv = require('osenv')
   , shell = require('shelljs')
-  , test_dir = path.join(osenv.tmpdir(), 'test_plugman') 
+  , test_dir = path.join(osenv.tmpdir(), 'test_plugman')
   , project_dir = path.join(test_dir, 'project')
   , src = path.join(project_dir, 'src')
   , dest = path.join(project_dir, 'dest')
@@ -29,10 +29,6 @@ var common = require('../../src/platforms/common')
 
 describe('common platform handler', function() {
     describe('resolveSrcPath', function() {
-        it('should throw if path cannot be resolved', function(){  
-            expect(function(){common.resolveSrcPath(test_dir, 'I_dont_exist')}).toThrow();
-        });
-        
         it('should not throw if path exists', function(){
             shell.mkdir('-p', test_dir);
             var target = path.join(test_dir, 'somefile');
@@ -48,50 +44,50 @@ describe('common platform handler', function() {
             expect(function(){common.resolveTargetPath(test_dir)}).toThrow();
             shell.rm('-rf', test_dir);
         });
-        
+
         it('should not throw if path cannot be resolved', function(){
             expect(function(){common.resolveTargetPath(test_dir, 'somefile')}).not.toThrow();
         });
     });
 
-    describe('copyFile', function() {    
+    describe('copyFile', function() {
         it('should throw if source path cannot be resolved', function(){
             expect(function(){common.copyFile(test_dir, src, project_dir, dest)}).toThrow();
         });
-        
+
         it('should throw if target path exists', function(){
             shell.mkdir('-p', dest);
             expect(function(){common.copyFile(test_dir, src, project_dir, dest)}).toThrow();
             shell.rm('-rf', dest);
         });
-        
+
         it('should call mkdir -p on target path', function(){
             shell.mkdir('-p', java_dir);
             fs.writeFileSync(java_file, 'contents', 'utf-8');
-            
+
             var s = spyOn(shell, 'mkdir').andCallThrough();
             var resolvedDest = common.resolveTargetPath(project_dir, dest);
-            
+
             common.copyFile(test_dir, java_file, project_dir, dest);
-            
+
             expect(s).toHaveBeenCalled();
             expect(s).toHaveBeenCalledWith('-p', path.dirname(resolvedDest));
-            shell.rm('-rf', project_dir);            
+            shell.rm('-rf', project_dir);
         });
-            
+
         it('should call cp source/dest paths', function(){
             shell.mkdir('-p', java_dir);
             fs.writeFileSync(java_file, 'contents', 'utf-8');
-            
+
             var s = spyOn(shell, 'cp').andCallThrough();
             var resolvedDest = common.resolveTargetPath(project_dir, dest);
-            
+
             common.copyFile(test_dir, java_file, project_dir, dest);
-            
+
             expect(s).toHaveBeenCalled();
-            expect(s).toHaveBeenCalledWith(java_file, resolvedDest);
+            expect(s).toHaveBeenCalledWith('-f', java_file, resolvedDest);
 
-            shell.rm('-rf', project_dir);         
+            shell.rm('-rf', project_dir);
         });
 
     });
@@ -100,34 +96,34 @@ describe('common platform handler', function() {
         it('should call fs.unlinkSync on the provided paths', function(){
             shell.mkdir('-p', java_dir);
             fs.writeFileSync(java_file, 'contents', 'utf-8');
-            
+
             var s = spyOn(fs, 'unlinkSync').andCallThrough();
-            common.deleteJava(project_dir, java_file); 
+            common.deleteJava(project_dir, java_file);
             expect(s).toHaveBeenCalled();
             expect(s).toHaveBeenCalledWith(path.resolve(project_dir, java_file));
-            
+
             shell.rm('-rf', java_dir);
         });
-        
+
         it('should delete empty directories after removing source code in a java src path
heirarchy', function(){
             shell.mkdir('-p', java_dir);
             fs.writeFileSync(java_file, 'contents', 'utf-8');
-            
-            common.deleteJava(project_dir, java_file); 
+
+            common.deleteJava(project_dir, java_file);
             expect(fs.existsSync(java_file)).not.toBe(true);
             expect(fs.existsSync(java_dir)).not.toBe(true);
             expect(fs.existsSync(path.join(src,'one'))).not.toBe(true);
-            
+
             shell.rm('-rf', java_dir);
         });
-        
+
         it('should never delete the top-level src directory, even if all plugins added were
removed', function(){
             shell.mkdir('-p', java_dir);
             fs.writeFileSync(java_file, 'contents', 'utf-8');
-            
-            common.deleteJava(project_dir, java_file); 
+
+            common.deleteJava(project_dir, java_file);
             expect(fs.existsSync(src)).toBe(true);
-            
+
             shell.rm('-rf', java_dir);
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/spec/prepare.spec.js
----------------------------------------------------------------------
diff --git a/spec/prepare.spec.js b/spec/prepare.spec.js
index 1531885..1e84759 100644
--- a/spec/prepare.spec.js
+++ b/spec/prepare.spec.js
@@ -1,5 +1,6 @@
 var platforms = require('../src/platforms'),
     prepare = require('../src/prepare'),
+    common  = require('../src/platforms/common');
     fs      = require('fs'),
     os      = require('osenv'),
     path    = require('path'),
@@ -48,14 +49,18 @@ describe('prepare', function() {
         expect(write).toHaveBeenCalledWith(js, jasmine.any(String), 'utf-8');
     });
     describe('handling of js-modules', function() {
-        var read, child_one;
+        var read, child_one, copySpy;
         beforeEach(function() {
             child_one = jasmine.createSpy('getchildren').andReturn([]);
             read = spyOn(fs, 'readFileSync').andReturn('JAVASCRIPT!');
-            platform_json.andReturn({installed_plugins:{plugin_one:'',plugin_two:''},dependent_plugins:{},prepare_queue:{uninstalled:[]}});
+            copySpy = spyOn(common, 'copyFile');
+            platform_json.andReturn({
+                installed_plugins: {plugin_one: '', plugin_two: ''},
+                dependent_plugins: {}, prepare_queue: {uninstalled:[]}
+            });
             findall.andReturn([
-                {attrib:{src:'somedir', name:'NAME'}, getchildren:child_one},
-                {attrib:{src:'someotherdir', name:'NAME'}, getchildren:child_one}
+                {attrib:{src:'somedir', name:'NAME', target:'sometarget'}, getchildren:child_one},
+                {attrib:{src:'someotherdir', name:'NAME', target:'someothertarget'}, getchildren:child_one}
             ]);
         });
         it('should create a plugins directory in an application\'s www directory', function()
{

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index c3b59ad..e0342ac 100644
--- a/src/install.js
+++ b/src/install.js
@@ -214,6 +214,7 @@ var runInstall = module.exports.runInstall = function runInstall(actions,
platfo
       , filtered_variables = {};
     var name         = plugin_et.findall('name').text;
     var plugin_id    = plugin_et.getroot().attrib['id'];
+    options = options || {};
 
 
     if (isPluginInstalled(plugins_dir, platform, plugin_id)) {
@@ -367,47 +368,42 @@ function handleInstall(actions, plugin_id, plugin_et, platform, project_dir,
plu
 
         // queue up native stuff
         sourceFiles && sourceFiles.forEach(function(item) {
-            actions.push(actions.createAction(handler["source-file"].install, 
-                                              [item, plugin_dir, project_dir, plugin_id],

-                                              handler["source-file"].uninstall, 
+            actions.push(actions.createAction(handler["source-file"].install,
+                                              [item, plugin_dir, project_dir, plugin_id],
+                                              handler["source-file"].uninstall,
                                               [item, project_dir, plugin_id]));
         });
 
         headerFiles && headerFiles.forEach(function(item) {
-            actions.push(actions.createAction(handler["header-file"].install, 
-                                             [item, plugin_dir, project_dir, plugin_id],

-                                             handler["header-file"].uninstall, 
+            actions.push(actions.createAction(handler["header-file"].install,
+                                             [item, plugin_dir, project_dir, plugin_id],
+                                             handler["header-file"].uninstall,
                                              [item, project_dir, plugin_id]));
         });
 
         resourceFiles && resourceFiles.forEach(function(item) {
-            actions.push(actions.createAction(handler["resource-file"].install, 
-                                              [item, plugin_dir, project_dir, plugin_id],

-                                              handler["resource-file"].uninstall, 
+            actions.push(actions.createAction(handler["resource-file"].install,
+                                              [item, plugin_dir, project_dir, plugin_id],
+                                              handler["resource-file"].uninstall,
                                               [item, project_dir, plugin_id]));
         });
         // CB-5238 custom frameworks only
         frameworkFiles && frameworkFiles.forEach(function(item) {
-            actions.push(actions.createAction(handler["framework"].install, 
-                                             [item, plugin_dir, project_dir, plugin_id],

-                                             handler["framework"].uninstall, 
+            actions.push(actions.createAction(handler["framework"].install,
+                                             [item, plugin_dir, project_dir, plugin_id],
+                                             handler["framework"].uninstall,
                                              [item, project_dir, plugin_id]));
         });
 
         libFiles && libFiles.forEach(function(item) {
-            actions.push(actions.createAction(handler["lib-file"].install, 
-                                                [item, plugin_dir, project_dir, plugin_id],
 
-                                                handler["lib-file"].uninstall, 
+            actions.push(actions.createAction(handler["lib-file"].install,
+                                                [item, plugin_dir, project_dir, plugin_id],
+                                                handler["lib-file"].uninstall,
                                                 [item, project_dir, plugin_id]));
+
         });
     }
 
-    // queue up asset installation
-    var common = require('./platforms/common');
-    assets && assets.forEach(function(asset) {
-        actions.push(actions.createAction(common.asset.install, [asset, plugin_dir, www_dir],
common.asset.uninstall, [asset, www_dir, plugin_id]));
-    });
-
     // run through the action stack
     return actions.process(platform, project_dir)
     .then(function(err) {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/src/platforms/android.js
----------------------------------------------------------------------
diff --git a/src/platforms/android.js b/src/platforms/android.js
index 04fcf64..038f92d 100644
--- a/src/platforms/android.js
+++ b/src/platforms/android.js
@@ -37,6 +37,8 @@ module.exports = {
     "source-file":{
         install:function(source_el, plugin_dir, project_dir, plugin_id) {
             var dest = path.join(source_el.attrib['target-dir'], path.basename(source_el.attrib['src']));
+            var target_path = common.resolveTargetPath(project_dir, dest);
+            if (fs.existsSync(target_path)) throw new Error('"' + target_path + '" already
exists!');
             common.copyFile(plugin_dir, source_el.attrib['src'], project_dir, dest);
         },
         uninstall:function(source_el, project_dir, plugin_id) {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/src/platforms/blackberry10.js
----------------------------------------------------------------------
diff --git a/src/platforms/blackberry10.js b/src/platforms/blackberry10.js
index 99d0504..d3709c0 100644
--- a/src/platforms/blackberry10.js
+++ b/src/platforms/blackberry10.js
@@ -39,6 +39,8 @@ module.exports = {
             var target = source_el.attrib['target-dir'] || plugin_id;
             TARGETS.forEach(function(arch) {
                 var dest = path.join("native", arch, "chrome", "plugin", target, path.basename(src));
+                var target_path = common.resolveTargetPath(project_dir, dest);
+                if (fs.existsSync(target_path)) throw new Error('"' + target_path + '" already
exists!');
                 common.copyFile(plugin_dir, src, project_dir, dest);
             });
         },

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/src/platforms/common.js
----------------------------------------------------------------------
diff --git a/src/platforms/common.js b/src/platforms/common.js
index 684690b..671e722 100644
--- a/src/platforms/common.js
+++ b/src/platforms/common.js
@@ -4,22 +4,19 @@ var shell = require('shelljs'),
 
 module.exports = {
     // helper for resolving source paths from plugin.xml
-    // throws File Not Found
     resolveSrcPath:function(plugin_dir, relative_path) {
         var full_path = path.resolve(plugin_dir, relative_path);
-        if (!fs.existsSync(full_path)) throw new Error('"' + full_path + '" not found!');
-        else return full_path;
+        return full_path;
     },
     // helper for resolving target paths from plugin.xml into a cordova project
-    // throws File Exists
     resolveTargetPath:function(project_dir, relative_path) {
         var full_path = path.resolve(project_dir, relative_path);
-        if (fs.existsSync(full_path)) throw new Error('"' + full_path + '" already exists!');
-        else return full_path;
+        return full_path;
     },
     // Many times we simply need to copy shit over, knowing if a source path doesnt exist
or if a target path already exists
     copyFile:function(plugin_dir, src, project_dir, dest) {
         src = module.exports.resolveSrcPath(plugin_dir, src);
+        if (!fs.existsSync(src)) throw new Error('"' + src + '" not found!');
         dest = module.exports.resolveTargetPath(project_dir, dest);
         shell.mkdir('-p', path.dirname(dest));
 
@@ -27,7 +24,7 @@ module.exports = {
         if(fs.statSync(src).isDirectory()) {
             shell.cp('-R', src+'/*', dest);
         } else {
-            shell.cp(src, dest);
+            shell.cp('-f', src, dest);
         }
     },
     // checks if file exists and then deletes. Error if doesn't exist

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/src/platforms/windows8.js
----------------------------------------------------------------------
diff --git a/src/platforms/windows8.js b/src/platforms/windows8.js
index 407d74c..908dc95 100644
--- a/src/platforms/windows8.js
+++ b/src/platforms/windows8.js
@@ -20,7 +20,8 @@
 var common = require('./common'),
     path = require('path'),
     glob = require('glob'),
-    w8jsproj = require('../util/w8jsproj');
+    fs = require('fs'),
+    w8jsproj = require('../util/w8jsproj'),
     xml_helpers = require('../util/xml-helpers');
 
 
@@ -45,13 +46,15 @@ module.exports = {
         install:function(source_el, plugin_dir, project_dir, plugin_id, project_file) {
             var targetDir = source_el.attrib['target-dir'] || '';
             var dest = path.join('www', 'plugins', plugin_id, targetDir, path.basename(source_el.attrib['src']));
+            var target_path = common.resolveTargetPath(project_dir, dest);
+            if (fs.existsSync(target_path)) throw new Error('"' + target_path + '" already
exists!');
             common.copyFile(plugin_dir, source_el.attrib['src'], project_dir, dest);
             // add reference to this file to jsproj.
             project_file.addSourceFile(dest);
         },
         uninstall:function(source_el, project_dir, plugin_id, project_file) {
             var dest = path.join('www', 'plugins', plugin_id,
-                                 source_el.attrib['target-dir'] ? source_el.attrib['target-dir']
: '', 
+                                 source_el.attrib['target-dir'] ? source_el.attrib['target-dir']
: '',
                                  path.basename(source_el.attrib['src']));
             common.removeFile(project_dir, dest);
             // remove reference to this file from csproj.

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/src/platforms/wp7.js
----------------------------------------------------------------------
diff --git a/src/platforms/wp7.js b/src/platforms/wp7.js
index b7946ef..b60697c 100644
--- a/src/platforms/wp7.js
+++ b/src/platforms/wp7.js
@@ -20,7 +20,8 @@
 var common = require('./common'),
     path = require('path'),
     glob = require('glob'),
-    csproj = require('../util/csproj');
+    fs = require('fs'),
+    csproj = require('../util/csproj'),
     xml_helpers = require('../util/xml-helpers');
 
 module.exports = {
@@ -42,6 +43,8 @@ module.exports = {
     "source-file":{
         install:function(source_el, plugin_dir, project_dir, plugin_id, project_file) {
             var dest = path.join('Plugins', plugin_id, source_el.attrib['target-dir'] ? source_el.attrib['target-dir']
: '', path.basename(source_el.attrib['src']));
+            var target_path = common.resolveTargetPath(project_dir, dest);
+            if (fs.existsSync(target_path)) throw new Error('"' + target_path + '" already
exists!');
             common.copyFile(plugin_dir, source_el.attrib['src'], project_dir, dest);
             // add reference to this file to csproj.
             project_file.addSourceFile(dest);

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/src/platforms/wp8.js
----------------------------------------------------------------------
diff --git a/src/platforms/wp8.js b/src/platforms/wp8.js
index 4c70695..4a74a1f 100644
--- a/src/platforms/wp8.js
+++ b/src/platforms/wp8.js
@@ -20,7 +20,8 @@
 var common = require('./common'),
     path = require('path'),
     glob = require('glob'),
-    csproj = require('../util/csproj');
+    fs = require('fs'),
+    csproj = require('../util/csproj'),
     xml_helpers = require('../util/xml-helpers');
 
 module.exports = {
@@ -42,6 +43,8 @@ module.exports = {
     "source-file":{
         install:function(source_el, plugin_dir, project_dir, plugin_id, project_file) {
             var dest = path.join('Plugins', plugin_id, source_el.attrib['target-dir'] ? source_el.attrib['target-dir']
: '', path.basename(source_el.attrib['src']));
+            var target_path = common.resolveTargetPath(project_dir, dest);
+            if (fs.existsSync(target_path)) throw new Error('"' + target_path + '" already
exists!');
             common.copyFile(plugin_dir, source_el.attrib['src'], project_dir, dest);
             // add reference to this file to csproj.
             project_file.addSourceFile(dest);
@@ -72,7 +75,7 @@ module.exports = {
     "framework":{
         install:function(el, plugin_dir, project_dir, plugin_id, project_file) {
             require('../../plugman').emit('verbose', 'wp8 framework install :: ' + plugin_id
 );
-            
+
             var src = el.attrib['src'];
             var dest = src; // if !isCustom, we will just add a reference to the file in
place
             var isCustom = el.attrib.custom == "true";

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 06e86d3..f3f3b8f 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -17,6 +17,8 @@
     under the License.
 */
 
+/* jshint node:true */
+
 var platform_modules = require('./platforms'),
     path            = require('path'),
     config_changes  = require('./util/config-changes'),
@@ -24,6 +26,7 @@ var platform_modules = require('./platforms'),
     wp7             = require('./platforms/wp7'),
     wp8             = require('./platforms/wp8'),
     windows8        = require('./platforms/windows8'),
+    common          = require('./platforms/common');
     fs              = require('fs'),
     shell           = require('shelljs'),
     util            = require('util'),
@@ -124,25 +127,33 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir,
www_
         var pluginDir = path.join(plugins_dir, plugin);
         if(fs.statSync(pluginDir).isDirectory()){
             var xml = xml_helpers.parseElementtreeSync(path.join(pluginDir, 'plugin.xml'));
-    
+
             var plugin_id = xml.getroot().attrib.id;
 
             // pluginMetadata is a mapping from plugin IDs to versions.
             pluginMetadata[plugin_id] = xml.getroot().attrib.version;
-    
+
             // add the plugins dir to the platform's www.
             var platformPluginsDir = path.join(wwwDir, 'plugins');
             // XXX this should not be here if there are no js-module. It leaves an empty
plugins/ directory
             shell.mkdir('-p', platformPluginsDir);
-    
-            var generalModules = xml.findall('./js-module');
+
+            var jsModules = xml.findall('./js-module');
+            var assets = xml.findall('asset');
             var platformTag = xml.find(util.format('./platform[@name="%s"]', platform));
-    
-            generalModules = generalModules || [];
-            var platformModules = platformTag ? platformTag.findall('./js-module') : [];
-            var allModules = generalModules.concat(platformModules);
-    
-            allModules.forEach(function(module) {
+
+            if (platformTag) {
+                assets = assets.concat(platformTag.findall('./asset'));
+                jsModules = jsModules.concat(platformTag.findall('./js-module'));
+            }
+
+            // Copy www assets described in <asset> tags.
+            assets = assets || [];
+            assets.forEach(function(asset) {
+                common.asset.install(asset, pluginDir, wwwDir);
+            });
+
+            jsModules.forEach(function(module) {
                 // Copy the plugin's files into the www directory.
                 // 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.
@@ -151,7 +162,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir,
www_
                 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 + '.';
                 if (module.attrib.name) {
@@ -160,7 +171,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir,
www_
                     var result = module.attrib.src.match(/([^\/]+)\.js/);
                     moduleName += result[1];
                 }
-    
+
                 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});\n';
@@ -168,13 +179,13 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir,
www_
                 if(platform == 'wp7' || platform == 'wp8' || platform == "windows8") {
                     wp_csproj.addSourceFile(path.join('www', 'plugins', plugin_id, fsPath));
                 }
-    
+
                 // Prepare the object for cordova_plugins.json.
                 var obj = {
                     file: ['plugins', plugin_id, module.attrib.src].join('/'),
                     id: moduleName
                 };
-    
+
                 // Loop over the children of the js-module tag, collecting clobbers, merges
and runs.
                 module.getchildren().forEach(function(child) {
                     if (child.tag.toLowerCase() == 'clobbers') {
@@ -191,7 +202,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir,
www_
                         obj.runs = true;
                     }
                 });
-    
+
                 // Add it to the list of module objects bound for cordova_plugins.json
                 moduleObjects.push(obj);
             });

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ddc20aaf/src/uninstall.js
----------------------------------------------------------------------
diff --git a/src/uninstall.js b/src/uninstall.js
index 9bdc359..e8a7ef7 100644
--- a/src/uninstall.js
+++ b/src/uninstall.js
@@ -22,6 +22,7 @@ module.exports = function(platform, project_dir, id, plugins_dir, options)
{
 
 // Returns a promise.
 module.exports.uninstallPlatform = function(platform, project_dir, id, plugins_dir, options)
{
+    options = options || {};
     if (!platform_modules[platform]) {
         return Q.reject(new Error(platform + " not supported."));
     }
@@ -164,8 +165,8 @@ function handleUninstall(actions, platform, plugin_id, plugin_et, project_dir,
w
         resourceFiles && resourceFiles.forEach(function(resource) {
             actions.push(actions.createAction(handler["resource-file"].uninstall, [resource,
project_dir], handler["resource-file"].install, [resource, plugin_dir, project_dir]));
         });
-        
-        // CB-5238 custom frameworks only 
+
+        // CB-5238 custom frameworks only
         frameworkFiles && frameworkFiles.forEach(function(framework) {
             actions.push(actions.createAction(handler["framework"].uninstall, [framework,
project_dir, plugin_id], handler["framework"].install, [framework, plugin_dir, project_dir]));
         });


Mime
View raw message