cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [11/25] js commit: catch exception for missing or invalid file path (cherry picked from commit 87cc336cb59f8df559a201fdb1e2a6251b57a06b)
Date Tue, 22 Oct 2013 15:45:21 GMT
catch exception for missing or invalid file path
(cherry picked from commit 87cc336cb59f8df559a201fdb1e2a6251b57a06b)


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

Branch: refs/heads/2.9.x
Commit: e13fbe7a44837031e70518b49ca1ddb6ecbd3a13
Parents: 5f9b670
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Thu Jul 11 15:59:31 2013 -0700
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Oct 22 11:36:10 2013 -0400

----------------------------------------------------------------------
 build/packager.js | 47 ++++++++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/e13fbe7a/build/packager.js
----------------------------------------------------------------------
diff --git a/build/packager.js b/build/packager.js
index 5026fbd..7e2f19b 100644
--- a/build/packager.js
+++ b/build/packager.js
@@ -188,28 +188,33 @@ function collectFiles(dir, id) {
 
     var result = {}    
     
-    var entries = fs.readdirSync(dir)
-    
-    entries = entries.filter(function(entry) {
-        if (entry.match(/\.js$/)) return true
-        
-        var stat = fs.statSync(path.join(dir, entry))
-        if (stat.isDirectory())  return true
-    })
+    try {
+        var entries = fs.readdirSync(dir)
+
+        entries = entries.filter(function(entry) {
+            if (entry.match(/\.js$/)) return true
+            
+            var stat = fs.statSync(path.join(dir, entry))
+            if (stat.isDirectory())  return true
+        })
+
+        entries.forEach(function(entry) {
+            var moduleId = path.join(id, entry)
+            var fileName = path.join(dir, entry)
+            
+            var stat = fs.statSync(fileName)
+            if (stat.isDirectory()) {
+                copyProps(result, collectFiles(fileName, moduleId))
+            }
+            else {
+                moduleId         = getModuleId(moduleId)
+                result[moduleId] = fileName
+            }
+        })
+    }
+    catch(ex) {
 
-    entries.forEach(function(entry) {
-        var moduleId = path.join(id, entry)
-        var fileName = path.join(dir, entry)
-        
-        var stat = fs.statSync(fileName)
-        if (stat.isDirectory()) {
-            copyProps(result, collectFiles(fileName, moduleId))
-        }
-        else {
-            moduleId         = getModuleId(moduleId)
-            result[moduleId] = fileName
-        }
-    })
+    }
     
     return copyProps({}, result)
 }


Mime
View raw message