Load extensions from the application support directory.

This commit is contained in:
Glenn Ruehle 2012-10-24 09:30:22 -07:00
Родитель 6a262f4365
Коммит bb8ad847d4
5 изменённых файлов: 52 добавлений и 12 удалений

6
.gitignore поставляемый
Просмотреть файл

@ -2,10 +2,10 @@ Thumbs.db
src/brackets.css
src/brackets.min.css
# ignore everything in the user extension directory EXCEPT the README
# ignore everything in the dev extension directory EXCEPT the README
# (so that the directory is non-empty and can be in git)
src/extensions/user/*
!src/extensions/user/README
src/extensions/dev/*
!src/extensions/dev/README
#OSX .DS_Store files
.DS_Store

Просмотреть файл

@ -110,16 +110,44 @@ define(function (require, exports, module) {
require("search/FindReplace");
require("utils/ExtensionUtils");
/**
* Returns the full path of the default user extensions directory. This is in the users
* application support directory, which is typically:
* /Users/<user>/Application Support/Brackets/extensions/user on the mac
* C:\Users\<user>\AppData\Roaming\Brackets\extensions\user on windows.
*/
function _getUserExtensionPath() {
return brackets.app.getApplicationSupportDirectory() + "/extensions/user";
}
// TODO: (issue 1029) Add timeout to main extension loading promise, so that we always call this function
// Making this fix will fix a warning (search for issue 1029) related to the global brackets 'ready' event.
function _initExtensions() {
// allow unit tests to override which plugin folder(s) to load
var paths = params.get("extensions") || "default,user";
var paths = params.get("extensions");
if (!paths) {
paths = "default,dev," + _getUserExtensionPath();
}
return Async.doInParallel(paths.split(","), function (item) {
var extensionPath,
relativePath;
// If the item has "/" in it, assume it is a full path. Otherwise, load
// from our source path + "/extensions/".
if (item.indexOf("/") === -1) {
extensionPath = FileUtils.getNativeBracketsDirectoryPath() + "/extensions/" + item;
relativePath = "extensions/" + item;
} else {
extensionPath = item;
relativePath = PathUtils.makePathRelative(extensionPath,
FileUtils.getNativeBracketsDirectoryPath() + "/");
}
return ExtensionLoader.loadAllExtensionsInNativeDirectory(
FileUtils.getNativeBracketsDirectoryPath() + "/extensions/" + item,
"extensions/" + item
extensionPath,
relativePath
);
});
}
@ -242,6 +270,16 @@ define(function (require, exports, module) {
ProjectManager.openProject(initialProjectPath).always(function () {
_initTest();
// Create a new DirectoryEntry and call getDirectory() on the user extension
// directory. If the directory doesn't exist, it will be created.
// Note that this is an async call and there are no success or failure functions passed
// in. If the directory *doesn't* exist, it will be created. Extension loading may happen
// before the directory is finished being created, but that is okay, since the extension
// loading will work correctly without this directory.
// If the directory *does* exist, nothing else needs to be done. It will be scanned normally
// during extension loading.
new NativeFileSystem.DirectoryEntry().getDirectory(_getUserExtensionPath(), {create: true});
// WARNING: AppInit.appReady won't fire if ANY extension fails to
// load or throws an error during init. To fix this, we need to
// make a change to _initExtensions (filed as issue 1029)

Просмотреть файл

@ -0,0 +1,6 @@
This directory contains extensions that are being developed. User-installed
extensions are placed in the "user" extensions directory, which can be accessed
by running the _Help > Show Extensions Folder_ menu command. The contents of
this directory (except the README file) are ignored by git.
(README also serves as a dummy file so this directory can be added to git.)

Просмотреть файл

@ -1,4 +0,0 @@
This directory contains extensions enabled by the user. The contents of
this directory (except the README file) are ignored by git.
(README also serves as a dummy file so this directory can be added to git.)

Просмотреть файл

@ -39,8 +39,8 @@ define(function (require, exports, module) {
Async = require("utils/Async"),
contexts = {},
globalConfig = {
"text" : "../../../thirdparty/text",
"i18n" : "../../../thirdparty/i18n"
"text" : FileUtils.getNativeBracketsDirectoryPath() + "/thirdparty/text",
"i18n" : FileUtils.getNativeBracketsDirectoryPath() + "/thirdparty/i18n"
};
/**