Serialize package upon deactivation

This commit is contained in:
Katrina Uychaco
2016-02-01 16:11:10 -08:00
parent 224b51d17c
commit 5e21f7bad9
2 changed files with 5 additions and 3 deletions

View File

@@ -445,11 +445,12 @@ describe "PackageManager", ->
expect(console.warn).not.toHaveBeenCalled()
it "passes the activate method the package's previously serialized state if it exists", ->
pack = atom.packages.loadPackage("package-with-serialization")
pack = null
waitsForPromise ->
pack.activate() # require main module
atom.packages.activatePackage("package-with-serialization").then (p) -> pack = p
runs ->
atom.packages.setPackageState("package-with-serialization", {someNumber: 77})
expect(pack.mainModule.someNumber).not.toBe 77
pack.mainModule.someNumber = 77
atom.packages.deactivatePackage("package-with-serialization")
spyOn(pack.mainModule, 'activate').andCallThrough()
waitsForPromise ->

View File

@@ -487,6 +487,7 @@ class PackageManager
# Deactivate the package with the given name
deactivatePackage: (name) ->
pack = @getLoadedPackage(name)
@serializePackage(pack)
pack.deactivate()
delete @activePackages[pack.name]
delete @activatingPackages[pack.name]