mirror of
https://github.com/atom/atom.git
synced 2026-01-22 13:28:01 -05:00
Make package activate optional
This commit is contained in:
1
spec/fixtures/packages/package-with-no-activate/index.js
vendored
Normal file
1
spec/fixtures/packages/package-with-no-activate/index.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = {}
|
||||
4
spec/fixtures/packages/package-with-no-activate/package.json
vendored
Normal file
4
spec/fixtures/packages/package-with-no-activate/package.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "package-with-no-activate",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
@@ -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 ->
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user