Expose package to user's init script?


#1

Packages can expose functionality to each other using the services API. Is there a suggested way to expose a service to the users init script? The simplest that I can think of is to attach the vended service to the atom global though that’s problematic long term of course.

Jesse


#2

You could create your own global, I suppose, though that’s probably just as ugly. Typically the way to expose things that can be used by the init.coffee is to have commands. If you need something more complex than that, you could have a class that can be required with something like:

packagePath = atom.packages.getPackageDirPath()[0]
myPackagePath = path.join(packagePath, 'my-package')
MyPackageService = require path.join(myPackagePath, 'lib/my-package-service')