You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by be...@apache.org on 2013/05/24 21:16:02 UTC

[6/6] wp7 commit: [CB-3495] clean project after creating

[CB-3495] clean project after creating


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

Branch: refs/heads/3.0.0
Commit: 0a264e3b3964863095f2be376f5be8330c345792
Parents: 8114e13
Author: Benn Mapes <be...@gmail.com>
Authored: Thu May 23 16:41:18 2013 -0700
Committer: Benn Mapes <be...@gmail.com>
Committed: Fri May 24 12:13:28 2013 -0700

----------------------------------------------------------------------
 bin/create.js                             |    3 ++
 templates/standalone/cordova/lib/clean.js |   43 +++++++++++++++---------
 2 files changed, 30 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/0a264e3b/bin/create.js
----------------------------------------------------------------------
diff --git a/bin/create.js b/bin/create.js
index a789e20..7d89d0a 100644
--- a/bin/create.js
+++ b/bin/create.js
@@ -203,6 +203,9 @@ function create(path, namespace, name) {
         }
     }
 
+    //clean up any Bin/obj or other generated files
+    exec('cscript ' + path + '\\cordova\\lib\\clean.js //nologo');
+
     Log("CREATE SUCCESS : " + path);
 
     // TODO: Name the project according to the arguments

http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/0a264e3b/templates/standalone/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/clean.js b/templates/standalone/cordova/lib/clean.js
index 3a8c871..b091425 100644
--- a/templates/standalone/cordova/lib/clean.js
+++ b/templates/standalone/cordova/lib/clean.js
@@ -50,32 +50,43 @@ function Log(msg, error) {
 
 // cleans any generated files in the cordova project
 function clean_project(path) {
-    if (fso.FolderExists(path + "\\obj")) {
-        fso.DeleteFolder(path + "\\obj");
-    }
-    if (fso.FolderExists(path + "\\Bin")) {
-        fso.DeleteFolder(path + "\\Bin");
+    delete_if_exists(path + "\\obj");
+    delete_if_exists(path + "\\Bin");
+
+    // checks to see if a .csproj file exists in the project root
+    if (fso.FolderExists(path)) {
+        var proj_folder = fso.GetFolder(path);
+        var proj_files = new Enumerator(proj_folder.Files);
+        for (;!proj_files.atEnd(); proj_files.moveNext()) {
+            if (fso.GetExtensionName(proj_files.item()) == 'user') {
+                delete_if_exists(proj_files.item())
+            } else if (fso.GetExtensionName(proj_files.item()) == 'sou') {
+                delete_if_exists(proj_files.item())
+            }
+        }
     }
-    //TODO: delete CordovaAppProj.csproj.user as well? Service References?
+    //TODO: delete Service References?
 }
 
 // cleans any files generated by build --debug
 function clean_debug(path) {
-    if (fso.FolderExists(path + "\\obj\\Debug")) {
-        fso.DeleteFolder(path + "\\obj\\Debug");
-    }
-    if (fso.FolderExists(path + "\\Bin\\Debug")) {
-        fso.DeleteFolder(path + "\\Bin\\Debug");
-    }
+    delete_if_exists(path + "\\obj\\Debug");
+    delete_if_exists(path + "\\Bin\\Debug");
 }
 
 // cleans any files generated by build --release
 function clean_release(path) {
-    if (fso.FolderExists(path + "\\obj\\Release")) {
-        fso.DeleteFolder(path + "\\obj\\Release");
+    delete_if_exists(path + "\\obj\\Release");
+    delete_if_exists(path + "\\Bin\\Release");
+}
+
+// deletes the path element if it exists
+function delete_if_exists(path) {
+    if (fso.FolderExists(path)) {
+        fso.DeleteFolder(path);
     }
-    if (fso.FolderExists(path + "\\Bin\\Release")) {
-        fso.DeleteFolder(path + "\\Bin\\Release");
+    else if (fso.FileExists(path)) {
+        fso.DeleteFile(path);
     }
 }