How do you use activationCommands in package.json?


#1

I get the deprecation errors saying to replace activationEvents with activationCommands but that never works for me. Am I supposed to do something other than replace the property name? Where is this documented? Searching in the api docs for activationCommands yields nothing.


#2

It’s on this page in the docs. For me replacing activationEvents with activationCommands just worked.


#3

You might need to do something like this (took me a while to figure it out too):


#4

Ohhh. It is changed from an array to an object.


#5

Those docs are flat out wrong …

activationCommands (Optional): an Array of Strings identifying commands that trigger your packages activation. You can delay the loading of your package until one of these events is triggered

#6

Hmmm… I could swear using an array worked a few days ago…


#7

#8

Now I’m having another problem. When I switch from this …

  "activationEvents": [
    "find-selection:find-next",
    "find-selection:find-previous"
  ],

… to …

  "activationCommands": {
    "atom-text-editor": "find-selection:find-next",
    "atom-text-editor": "find-selection:find-previous"
  },

find-selection doesn’t ever show in the command-palette. And it won’t activate using find-next because the second property atom-text-editor replaces the first.

I really need the proper docs for this. I’m not going to submit another issue to atom/atom until I can figure out what I’m supposed to be doing.


#9

Hey, you’re right, I didn’t notice that before but I’ve got the same problem with Zen. You’re commands will show up after you’re package has been activated. They’ve improved the lazy loading of packages but it’s a bit too lazy right now. Also this:

It’s a bit of a mess, not sure how it’s going to be fixed or if there is anything package authors can do about it right now.


#10

@leedohm, I can see the status (not good) of the atom/atom issue you posted, but can you tell me how activationCommands is supposed to be entered into package.json? The way I tried is obviously wrong.


Check out the updated documentation
#11

@kgrossjo suggested this (in a private message for some strange reason (grin)) and it worked perfectly.

  "activationCommands": {
    "atom-text-editor": ["find-selection:find-next", "find-selection:find-previous"]
  },

#12

@mark_hahn thanks so much for posting this solution!

I can’t even locate where this should be documented!

The only top hit of ‘atom activationCommands’ that I get is this page: https://atom.io/docs/v0.60.0/creating-a-package, but it does not have a version for the ‘latest’! I guess this comes back to this issue: https://github.com/atom/atom.io/issues/25, but I am still puzzled where it should redirect if the ‘latest’ version does not exist (or is not known to google, which is equivalent to does not exist).


#13

Just here to say that I also ran into confusion:

mark_hahn’s findings conflict with the documentation found here:
https://atom.io/docs/v0.186.0/your-first-package

(v0.186.0 was generated from “latest”)


#14

That documentation is not the latest. See the latest documentation at: https://atom.io/docs/latest


#15

Then you have some routing issues, because:

https://atom.io/docs/latest/your-first-package

redirects to:

https://atom.io/docs/v0.186.0/your-first-package

If the page doesn’t exist in the latest documentation, then a 404 should appear


#16

Yes, see the open issue here:


#17

Wow could Atom please redirect old documentation links to the current documentation.

Not a single one of the links to the documentation on this discussion actually brings you to where activationCommands is documented.

For anyone looking for the link here it is.


#18

We did, in the best way that we could by making them redirect to the new documentation landing page. The documentation system was completely redone and this meant that old links couldn’t be redirected in virtually all cases.