Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

A way to get extensions current directory #831

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

A way to get extensions current directory #831

jrowny opened this issue May 8, 2012 · 8 comments
Assignees

Comments

@jrowny
Copy link
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

@gruehle
Copy link
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/")

@jrowny
Copy link
Contributor Author

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

@gruehle
Copy link
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 "."

@jrowny
Copy link
Contributor Author

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

@pthiess
Copy link
Contributor

pthiess commented May 11, 2012

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

@redmunds
Copy link
Contributor

Fix in progress: #943

@redmunds
Copy link
Contributor

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

@jrowny
Copy link
Contributor Author

jrowny commented May 30, 2012

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants