Merge pull request #1504 from ajaxorg/fix/build

Fix snippet loading in build
This commit is contained in:
Lennart Kats 2013-07-07 01:03:44 -07:00
commit 5585535d98
2 changed files with 24 additions and 4 deletions

View file

@ -77,16 +77,26 @@ exports.moduleUrl = function(name, component) {
var parts = name.split("/");
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];
var path = options[component + "Path"];
if (path == null)
if (path == null) {
path = options.basePath;
} else if (sep == "/") {
component = sep = "";
}
if (path && path.slice(-1) != "/")
path += "/";
return path + component + "-" + base + this.get("suffix");
return path + component + sep + base + this.get("suffix");
};
exports.setModuleUrl = function(name, subst) {

View file

@ -60,6 +60,16 @@ module.exports = {
url = config.moduleUrl("foo/1", "theme");
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();
},
"test: define options" : function() {