From f1d90570b685d338b937068833124e61892e3487 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 16 Apr 2015 13:35:44 -0700 Subject: [PATCH 1/2] Check grammars/settings paths before reading asar seems to create and throw errors synchronously when these do not exist and fs.readdir is called. --- src/package.coffee | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/package.coffee b/src/package.coffee index de90c6cb4..9e7715754 100644 --- a/src/package.coffee +++ b/src/package.coffee @@ -305,8 +305,11 @@ class Package deferred = Q.defer() grammarsDirPath = path.join(@path, 'grammars') - fs.list grammarsDirPath, ['json', 'cson'], (error, grammarPaths=[]) -> - async.each grammarPaths, loadGrammar, -> deferred.resolve() + fs.exists grammarsDirPath, (grammarsDirExists) -> + return deferred.resolve() unless grammarsDirExists + + fs.list grammarsDirPath, ['json', 'cson'], (error, grammarPaths=[]) -> + async.each grammarPaths, loadGrammar, -> deferred.promise loadSettings: -> @@ -331,8 +334,11 @@ class Package else settingsDirPath = path.join(@path, 'settings') - fs.list settingsDirPath, ['json', 'cson'], (error, settingsPaths=[]) -> - async.each settingsPaths, loadSettingsFile, -> deferred.resolve() + fs.exists settingsDirPath, (settingsDirExists) -> + return deferred.resolve() unless settingsDirExists + + fs.list settingsDirPath, ['json', 'cson'], (error, settingsPaths=[]) -> + async.each settingsPaths, loadSettingsFile, -> deferred.resolve() deferred.promise serialize: -> From edbcf4023ee4420e0e9fd5407b97dab0b4902860 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 16 Apr 2015 14:37:52 -0700 Subject: [PATCH 2/2] Add back accidentally deleted resolve call --- src/package.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/package.coffee b/src/package.coffee index 9e7715754..8003d2d8d 100644 --- a/src/package.coffee +++ b/src/package.coffee @@ -309,7 +309,7 @@ class Package return deferred.resolve() unless grammarsDirExists fs.list grammarsDirPath, ['json', 'cson'], (error, grammarPaths=[]) -> - async.each grammarPaths, loadGrammar, -> + async.each grammarPaths, loadGrammar, -> deferred.resolve() deferred.promise loadSettings: ->