Handle errors in package.json gracefully

This commit is contained in:
Matt Colyer
2013-10-11 11:35:59 -07:00
parent cd633ede92
commit abd8bd1253
4 changed files with 8 additions and 2 deletions

View File

@@ -19,6 +19,10 @@ describe "the `atom` global", ->
expect(object.data).toBe 5
expect(pack.activateStylesheets).toHaveBeenCalled()
it "continues if the package fails to load", ->
config.set("core.disabledPackages", [])
expect(-> atom.loadPackage("package-that-throws-on-load")).not.toThrow()
describe ".unloadPackage(name)", ->
describe "when the package is active", ->
it "throws an error", ->

View File

@@ -0,0 +1 @@
INVALID

View File

@@ -63,7 +63,7 @@ beforeEach ->
config.set "editor.fontFamily", "Courier"
config.set "editor.fontSize", 16
config.set "editor.autoIndent", false
config.set "core.disabledPackages", ["package-that-throws-an-exception"]
config.set "core.disabledPackages", ["package-that-throws-an-exception", "package-that-throws-on-load"]
config.save.reset()
atom.config = config
window.config = config

View File

@@ -66,8 +66,9 @@ class PackageManager
if packagePath = @resolvePackagePath(name)
return pack if pack = @getLoadedPackage(name)
pack = Package.load(packagePath, options)
if pack.metadata.theme
if pack.metadata?.theme
atom.themes.register(pack)
else
@loadedPackages[pack.name] = pack