How can I access asset files that exists inside my package?

Hello everyone,

I want to create a smart package that calls phantom.js in order to scrape HTML data from other webpages.

In order to do that, I’ll have to do something like this:

var phantom = spawn('phantomjs', ['assets/phantom_driver.js.phantom', url]);

Where assets/phantom_driver.js.phantom is the file called by phantom of course. Not something that should be included when the package is loaded.

The problem I’m having is that I have no way of knowing where this file is located and end up with a Error while running phantomjsCan't open 'assets/phantom_driver.js.phantom' error.

Does anyone know how I can find the position of that file on runtime?

I ultimately made a function to to this for me. If there is a native or better way to do this, please call me out :smile: