This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8ff90f
commit 1223fac
Showing
3 changed files
with
68 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,9 +36,11 @@ define(function (require, exports, module) { | |
|
||
var NativeFileSystem = require("file/NativeFileSystem").NativeFileSystem, | ||
FileUtils = require("file/FileUtils"), | ||
Async = require("utils/Async"), | ||
contexts = {}, | ||
srcPath = FileUtils.getNativeBracketsDirectoryPath(); | ||
Async = require("utils/Async"); | ||
|
||
var _init = false, | ||
contexts = {}, | ||
srcPath = FileUtils.getNativeBracketsDirectoryPath(); | ||
|
||
// The native directory path ends with either "test" or "src". We need "src" to | ||
// load the text and i18n modules. | ||
|
@@ -238,6 +240,63 @@ define(function (require, exports, module) { | |
return _loadAll(directory, config, "unittests", testExtension); | ||
} | ||
|
||
/** | ||
* Load extensions. | ||
* | ||
* @param {?string} A list containing references to extension source | ||
* location. A source location may be either (a) a folder path | ||
* relative to src/extensions or (b) an absolute path. | ||
* @return {!$.Promise} A promise object that is resolved when all extensions complete loading. | ||
*/ | ||
function init(paths) { | ||
if (_init) { | ||
// Only init once. Return a resolved promise. | ||
return new $.Deferred().resolve().promise(); | ||
} | ||
|
||
if (!paths) { | ||
paths = "default,dev," + getUserExtensionPath(); | ||
} | ||
|
||
// Load extensions before restoring the project | ||
|
||
// 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. | ||
var extensionPath = getUserExtensionPath(); | ||
new NativeFileSystem.DirectoryEntry().getDirectory(extensionPath, | ||
{create: true}); | ||
|
||
// Create the extensions/disabled directory, too. | ||
var disabledExtensionPath = extensionPath.replace(/\/user$/, "/disabled"); | ||
new NativeFileSystem.DirectoryEntry().getDirectory(disabledExtensionPath, | ||
{create: true}); | ||
|
||
var promise = Async.doInParallel(paths.split(","), function (item) { | ||
var extensionPath = item; | ||
|
||
// 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; | ||
} | ||
|
||
return loadAllExtensionsInNativeDirectory(extensionPath); | ||
}); | ||
|
||
promise.done(function () { | ||
This comment has been minimized.
Sorry, something went wrong.
dangoor
Contributor
|
||
_init = true; | ||
}); | ||
|
||
return promise; | ||
} | ||
|
||
exports.init = init; | ||
exports.getUserExtensionPath = getUserExtensionPath; | ||
exports.getRequireContextForExtension = getRequireContextForExtension; | ||
exports.loadExtension = loadExtension; | ||
|
That should be a promise, not a promimse :)