mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-25 00:25:03 +08:00
rm(package): N1 does not use activationCommands
This commit is contained in:
parent
297e93dc8a
commit
57cd513a66
2 changed files with 6 additions and 74 deletions
|
@ -512,7 +512,7 @@ class PackageManager
|
||||||
|
|
||||||
for pack in packages
|
for pack in packages
|
||||||
promise = @activatePackage(pack.name)
|
promise = @activatePackage(pack.name)
|
||||||
promises.push(promise) unless pack.hasActivationCommands()
|
promises.push(promise)
|
||||||
@observeDisabledPackages()
|
@observeDisabledPackages()
|
||||||
promises
|
promises
|
||||||
|
|
||||||
|
|
|
@ -143,11 +143,10 @@ class Package
|
||||||
@loadKeymaps()
|
@loadKeymaps()
|
||||||
@loadMenus()
|
@loadMenus()
|
||||||
@loadStylesheets()
|
@loadStylesheets()
|
||||||
if not @hasActivationCommands()
|
mainModule = @requireMainModule()
|
||||||
mainModule = @requireMainModule()
|
return unless mainModule
|
||||||
return unless mainModule
|
@registerModelConstructors(mainModule.modelConstructors)
|
||||||
@registerModelConstructors(mainModule.modelConstructors)
|
@registerTaskConstructors(mainModule.taskConstructors)
|
||||||
@registerTaskConstructors(mainModule.taskConstructors)
|
|
||||||
|
|
||||||
catch error
|
catch error
|
||||||
console.warn "Failed to load package named '#{@name}'"
|
console.warn "Failed to load package named '#{@name}'"
|
||||||
|
@ -175,10 +174,7 @@ class Package
|
||||||
@activationDeferred = Q.defer()
|
@activationDeferred = Q.defer()
|
||||||
@measure 'activateTime', =>
|
@measure 'activateTime', =>
|
||||||
@activateResources()
|
@activateResources()
|
||||||
if @hasActivationCommands()
|
@activateNow()
|
||||||
@subscribeToActivationCommands()
|
|
||||||
else
|
|
||||||
@activateNow()
|
|
||||||
|
|
||||||
Q.all([@activationDeferred.promise])
|
Q.all([@activationDeferred.promise])
|
||||||
|
|
||||||
|
@ -348,70 +344,6 @@ class Package
|
||||||
path.join(@path, 'index')
|
path.join(@path, 'index')
|
||||||
@mainModulePath = fs.resolveExtension(mainModulePath, ["", Object.keys(require.extensions)...])
|
@mainModulePath = fs.resolveExtension(mainModulePath, ["", Object.keys(require.extensions)...])
|
||||||
|
|
||||||
hasActivationCommands: ->
|
|
||||||
for selector, commands of @getActivationCommands()
|
|
||||||
return true if commands.length > 0
|
|
||||||
false
|
|
||||||
|
|
||||||
subscribeToActivationCommands: ->
|
|
||||||
@activationCommandSubscriptions = new CompositeDisposable
|
|
||||||
for selector, commands of @getActivationCommands()
|
|
||||||
for command in commands
|
|
||||||
do (selector, command) =>
|
|
||||||
# Add dummy command so it appears in menu.
|
|
||||||
# The real command will be registered on package activation
|
|
||||||
@activationCommandSubscriptions.add NylasEnv.commands.add selector, command, ->
|
|
||||||
@activationCommandSubscriptions.add NylasEnv.commands.onWillDispatch (event) =>
|
|
||||||
return unless event.type is command
|
|
||||||
currentTarget = event.target
|
|
||||||
while currentTarget
|
|
||||||
if currentTarget.webkitMatchesSelector(selector)
|
|
||||||
@activationCommandSubscriptions.dispose()
|
|
||||||
@activateNow()
|
|
||||||
break
|
|
||||||
currentTarget = currentTarget.parentElement
|
|
||||||
|
|
||||||
getActivationCommands: ->
|
|
||||||
return @activationCommands if @activationCommands?
|
|
||||||
|
|
||||||
@activationCommands = {}
|
|
||||||
|
|
||||||
if @metadata.activationCommands?
|
|
||||||
for selector, commands of @metadata.activationCommands
|
|
||||||
@activationCommands[selector] ?= []
|
|
||||||
if _.isString(commands)
|
|
||||||
@activationCommands[selector].push(commands)
|
|
||||||
else if _.isArray(commands)
|
|
||||||
@activationCommands[selector].push(commands...)
|
|
||||||
|
|
||||||
if @metadata.activationEvents?
|
|
||||||
deprecate """
|
|
||||||
Use `activationCommands` instead of `activationEvents` in your package.json
|
|
||||||
Commands should be grouped by selector as follows:
|
|
||||||
```json
|
|
||||||
"activationCommands": {
|
|
||||||
"nylas-workspace": ["foo:bar", "foo:baz"],
|
|
||||||
"nylas-theme-wrap": ["foo:quux"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
"""
|
|
||||||
if _.isArray(@metadata.activationEvents)
|
|
||||||
for eventName in @metadata.activationEvents
|
|
||||||
@activationCommands['nylas-workspace'] ?= []
|
|
||||||
@activationCommands['nylas-workspace'].push(eventName)
|
|
||||||
else if _.isString(@metadata.activationEvents)
|
|
||||||
eventName = @metadata.activationEvents
|
|
||||||
@activationCommands['nylas-workspace'] ?= []
|
|
||||||
@activationCommands['nylas-workspace'].push(eventName)
|
|
||||||
else
|
|
||||||
for eventName, selector of @metadata.activationEvents
|
|
||||||
selector ?= 'nylas-workspace'
|
|
||||||
@activationCommands[selector] ?= []
|
|
||||||
@activationCommands[selector].push(eventName)
|
|
||||||
|
|
||||||
@activationCommands
|
|
||||||
|
|
||||||
# Does the given module path contain native code?
|
|
||||||
isNativeModule: (modulePath) ->
|
isNativeModule: (modulePath) ->
|
||||||
try
|
try
|
||||||
fs.listSync(path.join(modulePath, 'build', 'Release'), ['.node']).length > 0
|
fs.listSync(path.join(modulePath, 'build', 'Release'), ['.node']).length > 0
|
||||||
|
|
Loading…
Reference in a new issue