In this plugin I want to provide the user a way to configure how the plugin works by using a config file which can be checked into source control. In this file I want the user to define a Javascript file or a module which the plugin should load and then run. Something like this

The problem is the module exists in the node_modules folder for the project which defines the config file. BUT the plugin runs in atom which is a different folder and thus has a different set of paths which “require” uses to check for modules.

I was hoping someone might have a idea on how to solve this or if there is a special Atom way of dealing with this.

At the moment the only thing I can think of is either adding the project folder to the list of Module paths which “require” uses to check.

or

I can build the full path myself, which at the moment I feel is a hack.

This works well but feels,… dirty. I hope someone out there knows of something or is a little more creative than me.

If I stick with this then the only improvement I can think of is to make sure that when I remove the paths that I target them directly with _.pull() rather than just a pop(). There is no guarantee that they are still the last ones in the list after I call require.