mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Merge pull request #956 from atom/mc-bad-package
Make package loading more robust
This commit is contained in:
commit
0255faded1
@ -19,6 +19,14 @@ describe "the `atom` global", ->
|
||||
expect(object.data).toBe 5
|
||||
expect(pack.activateStylesheets).toHaveBeenCalled()
|
||||
|
||||
it "continues if the package has an invalid package.json", ->
|
||||
config.set("core.disabledPackages", [])
|
||||
expect(-> atom.loadPackage("package-with-broken-package-json")).not.toThrow()
|
||||
|
||||
it "continues if the package has an invalid keymap", ->
|
||||
config.set("core.disabledPackages", [])
|
||||
expect(-> atom.loadPackage("package-with-broken-keymap")).not.toThrow()
|
||||
|
||||
describe ".unloadPackage(name)", ->
|
||||
describe "when the package is active", ->
|
||||
it "throws an error", ->
|
||||
|
1
spec/fixtures/packages/package-with-broken-keymap/keymaps/broken.json
vendored
Normal file
1
spec/fixtures/packages/package-with-broken-keymap/keymaps/broken.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
INVALID
|
1
spec/fixtures/packages/package-with-broken-package-json/package.json
vendored
Normal file
1
spec/fixtures/packages/package-with-broken-package-json/package.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
INVALID
|
@ -63,7 +63,8 @@ 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-with-broken-package-json", "package-with-broken-keymap"]
|
||||
config.save.reset()
|
||||
atom.config = config
|
||||
window.config = config
|
||||
|
@ -28,16 +28,18 @@ class AtomPackage extends Package
|
||||
getType: -> 'atom'
|
||||
|
||||
load: ->
|
||||
@measure 'loadTime', =>
|
||||
try
|
||||
@metadata = Package.loadMetadata(@path)
|
||||
if @isTheme()
|
||||
@metadata = {}
|
||||
@stylesheets = []
|
||||
@keymaps = []
|
||||
@menus = []
|
||||
@grammars = []
|
||||
@scopedProperties = []
|
||||
else
|
||||
|
||||
@measure 'loadTime', =>
|
||||
try
|
||||
@metadata = Package.loadMetadata(@path)
|
||||
return if @isTheme()
|
||||
|
||||
@loadKeymaps()
|
||||
@loadMenus()
|
||||
@loadStylesheets()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user