Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

A way to get extensions current directory #831

Closed
jrowny opened this Issue · 8 comments

4 participants

@jrowny
Collaborator

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

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

@gruehle
Owner

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/")

@jrowny
Collaborator

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

@gruehle
Owner

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 "."

@jrowny
Collaborator

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";

@pthiess
Owner

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

@redmunds redmunds was assigned
@redmunds
Collaborator

Fix in progress: #943

@redmunds
Collaborator

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

@jrowny
Collaborator

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

@jrowny jrowny closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.