DEV: Improve colocated component rootName logic (#18708)
The complex regex-based detection was based on Ember CLI's implementation, which is necessarily generic and needs to auto-detect the name. In our case, we know the name of the plugin so we can just pass it in - no need for dynamic detection. This resolves issues when there are other files in the `discourse/plugins/{name}` directory which are sorted before `discourse/`
This commit is contained in:
parent
db0dbdf89a
commit
0a33c507d9
|
@ -3,17 +3,12 @@ const ColocatedTemplateProcessor = require("ember-cli-htmlbars/lib/colocated-bro
|
|||
module.exports = class DiscoursePluginColocatedTemplateProcessor extends (
|
||||
ColocatedTemplateProcessor
|
||||
) {
|
||||
constructor(tree, discoursePluginName) {
|
||||
super(tree);
|
||||
this.discoursePluginName = discoursePluginName;
|
||||
}
|
||||
|
||||
detectRootName() {
|
||||
const entries = this.currentEntries().filter((e) => !e.isDirectory());
|
||||
|
||||
const path = entries[0]?.relativePath;
|
||||
|
||||
const match = path?.match(
|
||||
/^discourse\/plugins\/(?<name>[^/]+)\/discourse\//
|
||||
);
|
||||
|
||||
if (match) {
|
||||
return `discourse/plugins/${match.groups.name}/discourse`;
|
||||
}
|
||||
return `discourse/plugins/${this.discoursePluginName}/discourse`;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -171,7 +171,7 @@ module.exports = {
|
|||
|
||||
tree = RawHandlebarsCompiler(tree);
|
||||
|
||||
tree = new DiscoursePluginColocatedTemplateProcessor(tree);
|
||||
tree = new DiscoursePluginColocatedTemplateProcessor(tree, pluginName);
|
||||
tree = this.compileTemplates(tree);
|
||||
|
||||
tree = this.processedAddonJsFiles(tree);
|
||||
|
|
Loading…
Reference in New Issue