Disabling packages in deactivate


I’m working on a package that uses atom.packages to change package states and some of the functions behave a little strange.

Let’s take a simple example:

module.exports =
  activate: ->
    console.log 'activate called'

  deactivate: ->
    console.log 'deactivate called'

This works just as you would expect:

  • atom.packages.disablePackage('test-package') and atom.packages.deactivatePackage('test-package') print deactivate called

  • atom.packages.enablePackage('test-package') and atom.packages.activatePackage('test-package') print activate called

  • Reloading atom does not print anything but that’s another story.

My problem is this: I want to disable (not deactivate, disable) other packages when my package gets deactivated.
Naturally I tried this:

deactivate: ->
  console.log 'deactivate called'
  atom.packages.disablePackage('status-bar') # status-bar is just an example

The functions still behave as expected, but when I deactivate the package by closing atom then core.disabledPackages does not contain the disabled package and in this example status-bar loads the next time I start atom.

The second way to disable packages is by setting core.disabledPackages manually:

deactivate: ->
  console.log 'deactivate called'
  atom.config.set('core.disabledPackages', ['status-bar'])

Now things get even weirder:

atom.packages.disablePackage('test-package') => 'deactivate called'
atom.packages.enablePackage('test-package')  => Nothing
atom.packages.enablePackage('test-package')  => Nothing
atom.packages.disablePackage('test-package') => Nothing
atom.packages.enablePackage('test-package')  => 'activate called'

Reloading/Closing atom still does not write anything to core.disabledPackages.

Is there a way to write to core.disabledPackages when my package deactivates ?

atom 1.0.19-5f4f6d2 on 4.2.2-1-ARCH Linux



To answer my own question:

deactivate: ->
  atom.config.set('core.disabledPackages', ['status-bar'])

atom.config.save is not part of the public API but it seems to work (for now).


Hey, I’m having exactly the same problem now, but atom.config.save() doesn’t do anything. Any other ideas?