Merge pull request #1504 from ajaxorg/fix/build
Fix snippet loading in build
This commit is contained in:
commit
5585535d98
2 changed files with 24 additions and 4 deletions
|
|
@ -77,16 +77,26 @@ exports.moduleUrl = function(name, component) {
|
||||||
|
|
||||||
var parts = name.split("/");
|
var parts = name.split("/");
|
||||||
component = component || parts[parts.length - 2] || "";
|
component = component || parts[parts.length - 2] || "";
|
||||||
var base = parts[parts.length - 1].replace(component, "").replace(/(^[\-_])|([\-_]$)/, "");
|
|
||||||
|
// todo make this configurable or get rid of '-'
|
||||||
|
var sep = component == "snippets" ? "/" : "-";
|
||||||
|
var base = parts[parts.length - 1];
|
||||||
|
if (sep == "-") {
|
||||||
|
var re = new RegExp("^" + component + "[\-_]|[\-_]" + component + "$", "g");
|
||||||
|
base = base.replace(re, "");
|
||||||
|
}
|
||||||
|
|
||||||
if (!base && parts.length > 1)
|
if ((!base || base == component) && parts.length > 1)
|
||||||
base = parts[parts.length - 2];
|
base = parts[parts.length - 2];
|
||||||
var path = options[component + "Path"];
|
var path = options[component + "Path"];
|
||||||
if (path == null)
|
if (path == null) {
|
||||||
path = options.basePath;
|
path = options.basePath;
|
||||||
|
} else if (sep == "/") {
|
||||||
|
component = sep = "";
|
||||||
|
}
|
||||||
if (path && path.slice(-1) != "/")
|
if (path && path.slice(-1) != "/")
|
||||||
path += "/";
|
path += "/";
|
||||||
return path + component + "-" + base + this.get("suffix");
|
return path + component + sep + base + this.get("suffix");
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.setModuleUrl = function(name, subst) {
|
exports.setModuleUrl = function(name, subst) {
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,16 @@ module.exports = {
|
||||||
url = config.moduleUrl("foo/1", "theme");
|
url = config.moduleUrl("foo/1", "theme");
|
||||||
assert.equal(url, "a/b1.js");
|
assert.equal(url, "a/b1.js");
|
||||||
|
|
||||||
|
url = config.moduleUrl("snippets/js");
|
||||||
|
assert.equal(url, "a/b/snippets/js.js");
|
||||||
|
|
||||||
|
config.setModuleUrl("snippets/js", "_.js");
|
||||||
|
url = config.moduleUrl("snippets/js");
|
||||||
|
assert.equal(url, "_.js");
|
||||||
|
|
||||||
|
url = config.moduleUrl("ace/ext/textarea");
|
||||||
|
assert.equal(url, "a/b/ext-textarea.js");
|
||||||
|
|
||||||
assert.equal();
|
assert.equal();
|
||||||
},
|
},
|
||||||
"test: define options" : function() {
|
"test: define options" : function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue