diff --git a/.gitignore b/.gitignore index c82216832..fc2fb4eb7 100644 --- a/.gitignore +++ b/.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 diff --git a/src/brackets.js b/src/brackets.js index 634eb04b8..a04537d68 100644 --- a/src/brackets.js +++ b/src/brackets.js @@ -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//Application Support/Brackets/extensions/user on the mac + * C:\Users\\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) diff --git a/src/extensions/dev/README.txt b/src/extensions/dev/README.txt new file mode 100644 index 000000000..aaae1c23f --- /dev/null +++ b/src/extensions/dev/README.txt @@ -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.) diff --git a/src/extensions/user/README.txt b/src/extensions/user/README.txt deleted file mode 100644 index 4b3e83f0e..000000000 --- a/src/extensions/user/README.txt +++ /dev/null @@ -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.) diff --git a/src/utils/ExtensionLoader.js b/src/utils/ExtensionLoader.js index c4da6bb41..4eb66acc4 100644 --- a/src/utils/ExtensionLoader.js +++ b/src/utils/ExtensionLoader.js @@ -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" }; /**