You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2013/05/07 17:18:43 UTC

[06/30] git commit: [wp7] Empty node handling, always modify csproj so Visual Studio will notice and reload it. Plugins folder use does not require project changes

[wp7] Empty node handling, always modify csproj so Visual Studio will notice and reload it. Plugins folder use does not require project changes


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

Branch: refs/heads/future
Commit: 9d1dd499702f7b796e605820153e1d6e873a0f3e
Parents: c646049
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Apr 16 12:36:50 2013 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Mon Apr 22 16:28:05 2013 -0700

----------------------------------------------------------------------
 platforms/wp7.js                     |   47 +++++++++++++++++-----------
 test/plugins/ChildBrowser/plugin.xml |    7 +----
 2 files changed, 29 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9d1dd499/platforms/wp7.js
----------------------------------------------------------------------
diff --git a/platforms/wp7.js b/platforms/wp7.js
index 1fec63d..936361e 100644
--- a/platforms/wp7.js
+++ b/platforms/wp7.js
@@ -18,9 +18,7 @@
 */
 
 /*
-$ node plugman --platform wp7 
-  --project '/c//users/jesse/documents/visual studio 2012/Projects/TestPlugin7/' 
-  --plugin '.\test\plugins\ChildBrowser\'
+node plugman --platform wp7 --project '/c//users/jesse/documents/visual studio 2012/Projects/TestPlugin7/' --plugin '.\test\plugins\ChildBrowser\'
 */
 
 var fs = require('fs'),
@@ -101,12 +99,17 @@ function install(project_dir, plugin_dir, plugin_et, variables) {
 
     // child is the configNode child that we will insert into csproj
     var child = configNode.find('*'); 
-    var newNodeText = new et.ElementTree(child).write({xml_declaration:false});
-        
-    newNodeText = newNodeText.split("&#xA;").join("\n").split("&#xD;").join("\r");
-    
+    // we use empty text as a default, so we always modify the project file so Visual Studio will notice if open.
+    var newNodeText = "";
+    if(child) {
+
+      newNodeText = new et.ElementTree(child).write({xml_declaration:false});
+      newNodeText = newNodeText.split("&#xA;").join("\n").split("&#xD;").join("\r");
+      newNodeText += "\n\r";
+    }
+
     // insert text right before closing tag
-    var newDocStr = docStr.replace("</Project>",newNodeText + "\n\r</Project>");
+    var newDocStr = docStr.replace("</Project>", newNodeText + "</Project>");
 
     // save it, and get out
     fs.writeFileSync(projPath, newDocStr);
@@ -134,17 +137,23 @@ function uninstall(project_dir, plugin_dir, plugin_et, variables) {
 
     // child is the configNode child that we will insert into csproj
     var child = configNode.find('*'); 
-    var newNodeText = new et.ElementTree(child).write({xml_declaration:false});
-        
-    newNodeText = newNodeText.split("&#xA;").join("\n").split("&#xD;").join("\r");
-    
-    // insert text right before closing tag
-    var splitString = docStr.split(newNodeText);
-    console.log("split length = " + splitString.length);
-    var newDocStr = splitString.join("");
-
-    // save it, and get out
-    fs.writeFileSync(projPath, newDocStr);
+    if(child) {
+      var newNodeText = new et.ElementTree(child).write({xml_declaration:false});
+          
+      newNodeText = newNodeText.split("&#xA;").join("\n").split("&#xD;").join("\r");
+      
+      // insert text right before closing tag
+      var splitString = docStr.split(newNodeText);
+      console.log("split length = " + splitString.length);
+      var newDocStr = splitString.join("");
+
+      // save it, and get out
+      fs.writeFileSync(projPath, newDocStr);
+    }
+    else {
+      // this just lets Visual Studio know to reload the project if it is open
+      fs.writeFileSync(projPath, docStr);
+    }
   });
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9d1dd499/test/plugins/ChildBrowser/plugin.xml
----------------------------------------------------------------------
diff --git a/test/plugins/ChildBrowser/plugin.xml b/test/plugins/ChildBrowser/plugin.xml
index 6998ec4..d92c1c4 100644
--- a/test/plugins/ChildBrowser/plugin.xml
+++ b/test/plugins/ChildBrowser/plugin.xml
@@ -114,12 +114,7 @@
                      target-dir="Plugins\" />
 
         <!-- modify the project file to include the added files -->
-        <config-file target=".csproj" parent=".">
-            <ItemGroup>
-                <Compile Include="Plugins\\ChildBrowserCommand.cs"/>
-                <Content Include="www\\childbrowser.js" />
-                <Content Include="www\\childbrowser\\**"/>
-            </ItemGroup>    
+        <config-file target=".csproj" parent=".">  
         </config-file> 
 
     </platform>