mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Make immediate package loading work
This commit is contained in:
@@ -60,19 +60,34 @@ class AtomPackage extends Package
|
||||
@grammars = []
|
||||
@scopedProperties = []
|
||||
|
||||
activate: ({immediate}={}) ->
|
||||
activate: ->
|
||||
return @activationDeferred.promise if @activationDeferred?
|
||||
|
||||
@activationDeferred = Q.defer()
|
||||
@measure 'activateTime', =>
|
||||
@activateResources()
|
||||
if @metadata.activationEvents? and not immediate
|
||||
if @metadata.activationEvents?
|
||||
@subscribeToActivationEvents()
|
||||
else
|
||||
@activateNow()
|
||||
|
||||
@activationDeferred.promise
|
||||
|
||||
# Deprecated
|
||||
activateSync: ({immediate}={}) ->
|
||||
@activateResources()
|
||||
if @metadata.activationEvents? and not immediate
|
||||
@subscribeToActivationEvents()
|
||||
else
|
||||
try
|
||||
@activateConfig()
|
||||
@activateStylesheets()
|
||||
if @requireMainModule()
|
||||
@mainModule.activate(atom.packages.getPackageState(@name) ? {})
|
||||
@mainActivated = true
|
||||
catch e
|
||||
console.warn "Failed to activate package named '#{@name}'", e.stack
|
||||
|
||||
activateNow: ->
|
||||
try
|
||||
@activateConfig()
|
||||
|
||||
@@ -98,11 +98,12 @@ class PackageManager
|
||||
@activePackages[pack.name] = pack
|
||||
pack
|
||||
|
||||
# Deprecated
|
||||
activatePackageSync: (name, options) ->
|
||||
return pack if pack = @getActivePackage(name)
|
||||
if pack = @loadPackage(name)
|
||||
@activePackages[pack.name] = pack
|
||||
pack.activate(options)
|
||||
pack.activateSync(options)
|
||||
pack
|
||||
|
||||
# Private: Deactivate all packages
|
||||
|
||||
Reference in New Issue
Block a user