Noob question about multiple files in Atom packages


#1

This is more of a general Node question. I’m trying to clean up one of my packages by splitting it into several files.

Here’s a minimal representation of what I’m trying to do:

First file:

# main.coffee
IncludeFile = require './include' # TAKE NOTE OF THIS
{CompositeDisposable} = require 'atom'

module.exports = MinTest =
  subscriptions: null

  activate: (state) ->CompositeDisposable
    @subscriptions = new CompositeDisposable

    # TAKE NOTE OF THIS AS WELL
    @subscriptions.add atom.commands.add 'atom-workspace', 'test:notify': => IncludeFile.sayHello()

  deactivate: ->
    @subscriptions.dispose()

Second file:

# include.coffee
module.exports =
    sayHello: ->
      atom.notification.addInfo( 'Hello world!', dismissable: true)

When running the command, it will produce an error Uncaught TypeError: Cannot read property 'addInfo' of undefined. I’ve looked at other packages, and none of them requires atom in included files to have access to methods. What am I missing here?


#2

atom.notifications, not atom.notification ?


#3

I think that was it :smile_cat:

Thank you!