forked from humphd/brackets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBrambleExtensionLoader.js
More file actions
126 lines (111 loc) · 4.16 KB
/
Copy pathBrambleExtensionLoader.js
File metadata and controls
126 lines (111 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define */
/**
* BrambleExtensionLoader allows optional enabling/disabling of extensions
* based on query string params.
*/
define(function (require, exports, module) {
"use strict";
var basePath = PathUtils.directory(window.location.href);
/**
* We have a set of defaults we load if not instructed to do otherwise
* via the disableExtensions query param. These live in src/extensions/default/*
*/
var brambleDefaultExtensions = [
"CSSCodeHints",
"HTMLCodeHints",
"JavaScriptCodeHints",
"InlineColorEditor",
"JavaScriptQuickEdit",
"QuickOpenCSS",
"QuickOpenHTML",
"QuickOpenJavaScript",
"QuickView",
// Custom extensions we want loaded by default
"bramble",
"Autosave",
"brackets-paste-and-indent",
"BrambleUrlCodeHints"
];
/**
* There are some Brackets default extensions that we don't load
* but which a user might want to enable (note: not all the defaults
* they ship will work in a browser, so they aren't all here). We
* support loading these below via the enableExtensions param.
*/
var bracketsDefaultExtensions = [
"SVGCodeHints",
"HtmlEntityCodeHints",
"LESSSupport",
"CloseOthers",
"InlineTimingFunctionEditor",
"WebPlatformDocs",
"CodeFolding",
"JSLint",
"QuickOpenCSS",
"RecentProjects",
"UrlCodeHints"
];
/**
* Other extensions we've tested and deemed useful in the Bramble context.
* These live in src/extensions/extra/* and are usually submodules. If you
* add a new extension there, update this array also. You can have this load
* by adding the extension name to the enableExtensions query param.
*/
var extraExtensions = [
"brackets-cdn-suggestions", // https://github.com/szdc/brackets-cdn-suggestions
"HTMLHinter",
"MDNDocs",
"SVGasXML"
];
// Disable any extensions we found on the query string's disableExtensions param
function _processDefaults(disableExtensions) {
if(disableExtensions) {
disableExtensions.split(",").forEach(function (ext) {
ext = ext.trim();
var idx = brambleDefaultExtensions.indexOf(ext);
if (idx > -1) {
console.log('[Brackets] Disabling default extension `' + ext + '`');
brambleDefaultExtensions.splice(idx, 1);
}
});
}
return brambleDefaultExtensions.map(function (ext) {
return {
name: ext,
path: basePath + "extensions/default/" + ext
};
});
}
// Add any extra extensions we found on the query string's enableExtensions param
function _processExtras(enableExtensions) {
var extras = [];
if(enableExtensions) {
enableExtensions.split(",").forEach(function (ext) {
ext = ext.trim();
// Extension is in src/extensions/extra/*
if (extraExtensions.indexOf(ext) > -1) {
console.log('[Brackets] Loading additional extension `' + ext + '`');
extras.push({
name: ext,
path: basePath + "extensions/extra/" + ext
});
}
// Extension is in src/extensions/default/* (we don't enable all Brackets exts)
if (bracketsDefaultExtensions.indexOf(ext) > -1) {
console.log('[Brackets] Loading additional extension `' + ext + '`');
extras.push({
name: ext,
path: basePath + "extensions/default/" + ext
});
}
});
}
return extras;
}
exports.getExtensionList = function(params) {
return []
.concat(_processDefaults(params.get("disableExtensions")))
.concat(_processExtras(params.get("enableExtensions")));
};
});