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

Commit

Permalink
Use the global RequireJS config for ExtensionLoader. Fixes #1087
Browse files Browse the repository at this point in the history
Signed-off-by: petetnt <[email protected]>
  • Loading branch information
petetnt committed Aug 20, 2016
1 parent bf9b07d commit fb60e92
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/utils/ExtensionLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ define(function (require, exports, module) {
FileUtils = require("file/FileUtils"),
Async = require("utils/Async"),
ExtensionUtils = require("utils/ExtensionUtils"),
UrlParams = require("utils/UrlParams").UrlParams;
UrlParams = require("utils/UrlParams").UrlParams,
PathUtils = require("thirdparty/path-utils/path-utils");

// default async initExtension timeout
var INIT_EXTENSION_TIMEOUT = 10000;
Expand All @@ -61,10 +62,14 @@ define(function (require, exports, module) {
// load the text and i18n modules.
srcPath = srcPath.replace(/\/test$/, "/src"); // convert from "test" to "src"

var globalConfig = {
"text" : srcPath + "/thirdparty/text/text",
"i18n" : srcPath + "/thirdparty/i18n/i18n"
};

// Retrieve the global paths
var globalPaths = brackets._getGlobalRequireJSConfig().paths;

// Convert the relative paths to absolute
Object.keys(globalPaths).forEach(function (key) {
globalPaths[key] = PathUtils.makePathAbsolute(srcPath + "/" + globalPaths[key]);
});

/**
* Returns the full path of the default user extensions directory. This is in the users
Expand Down Expand Up @@ -157,8 +162,7 @@ define(function (require, exports, module) {
var extensionConfig = {
context: name,
baseUrl: config.baseUrl,
/* FIXME (issue #1087): can we pass this from the global require context instead of hardcoding twice? */
paths: globalConfig,
paths: globalPaths,
locale: brackets.getLocale()
};

Expand Down
7 changes: 7 additions & 0 deletions src/utils/Global.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,12 @@ define(function (require, exports, module) {
// only be able to load modules that have already been loaded once.
global.brackets.getModule = require;

/* API for retrieving the global RequireJS config
* For internal use only
*/
global.brackets._getGlobalRequireJSConfig = function () {
return global.require.s.contexts._.config;
};

exports.global = global;
});

0 comments on commit fb60e92

Please sign in to comment.