A way to get extensions current directory #831

Closed
jrowny opened this Issue May 8, 2012 · 8 comments

Projects

None yet

4 participants

Contributor
jrowny commented May 8, 2012

Currently I have FileUtils.getNativeBracketsDirectoryPath() + "/extensions/user/brackets-snippets/data"

Would be awesome if I had something to get the extension's own directory

Member
gruehle commented May 8, 2012

You can use require.toUrl() to make a path relative to the extension's own directory. For example:

var dataDirectory = require.toUrl("/extensions/user/brackets-snippets/data/")

Contributor
jrowny commented May 8, 2012

toUrl seems to return a reference to a JS file. Doesn't work for a directory. require.toUrl('data'); returns \extensions\user\brackets-snippetes\data.js

Member
gruehle commented May 9, 2012

Bummer, you're right, it doesn't work right for a directory. In the meantime you could use toUrl("data/.") and just strip the final "."

Contributor
jrowny commented May 9, 2012

looks like you can also use module.uri.replace('main.js', '');

for example, to load from the data folder of my extension, I can do:
var directory = FileUtils.getNativeBracketsDirectoryPath() + "/" + module.uri.replace('main.js', '') + "data";

Member
pthiess commented May 11, 2012

Moving to the backlog - we need to prioritize probably a number of extensibility stories.

@redmunds redmunds was assigned May 27, 2012
Contributor

Fix in progress: #943

Contributor

Fixed. I added FileUtils.getNativeModuleDirectoryPath(). Take a look at src/extensions/disabled/JavaScriptInlineEditor/unittests.js for an example.

Contributor
jrowny commented May 30, 2012

Awesome, just tried it and it works great. Thanks!

@jrowny jrowny closed this May 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment