I'm looking for the canonical way to access the directory that belongs to a running extension. At the moment I have this kludge. It allows me to access a .json located in the same directory as main.js.
var support_dir = brackets.app.getApplicationSupportDirectory(),
precursor_path,
precursor_file = "package.json"; // where this represents some config file.
support_dir += "/extensions/user/zeffii.precursor/";
precursor_path = support_dir + precursor_file;
var prototypes;
$.getJSON(precursor_path, function (data) {
prototypes = data;
});
This should work:
var ExtensionUtils = brackets.getModule("utils/ExtensionUtils");
var path = ExtensionUtils.getModulePath(module);
(Where module
comes from the define(function (require, exports, module) {
at the top of your extension module).