Make package activate optional

This commit is contained in:
Kevin Sawicki
2015-02-25 11:16:06 -08:00
parent 2afb0722c0
commit bfe3bc3659
4 changed files with 17 additions and 1 deletions

View File

@@ -0,0 +1 @@
module.exports = {}

View File

@@ -0,0 +1,4 @@
{
"name": "package-with-no-activate",
"version": "1.0.0"
}

View File

@@ -220,6 +220,17 @@ describe "PackageManager", ->
expect(console.error).not.toHaveBeenCalled()
expect(console.warn).not.toHaveBeenCalled()
describe "when the package does not export an activate function", ->
it "activates the package and does not throw an exception or log a warning", ->
spyOn(console, "warn")
expect(-> atom.packages.activatePackage('package-with-no-activate')).not.toThrow()
waitsFor ->
atom.packages.isPackageActive('package-with-no-activate')
runs ->
expect(console.warn).not.toHaveBeenCalled()
it "passes the activate method the package's previously serialized state if it exists", ->
pack = null
waitsForPromise ->

View File

@@ -157,7 +157,7 @@ class Package
@activateConfig()
@activateStylesheets()
if @requireMainModule()
@mainModule.activate(atom.packages.getPackageState(@name) ? {})
@mainModule.activate?(atom.packages.getPackageState(@name) ? {})
@mainActivated = true
@activateServices()
catch e