Overriding package.menu and package.keymaps


#1

I am trying to figure out how to override the menu and keymaps object.

I have 2 files. package.coffee and modules/module.coffee.

package.coffee will load in module.coffee and pull the menu and keymap object. What I want to do, is concatenate what they specify, into the actual package’s keymap and menu objects. What am I doing wrong?

package.coffee

fs = require 'fs'

module.exports =
  keymaps: []
  menus: []
  modules: null
  modulesPath: atom.packages.packageDirPaths[0] + '/lib/modules'

  activate: (state) ->
    fs.readdir(
      @modulesPath,
      (err, files, _this) ->
        throw err if err

        for file in files
          Module = require './modules/' + file.split('.')[0]
          m = new Module()

          # assign keymaps
          module.exports.keymaps = module.exports.keymaps.concat m.keymap if m.keymap

          # assign menus
          module.exports.menus   = module.exports.menus.concat   m.menu   if m.menu
    )