Skip to content

Commit e86071c

Browse files
marklundinCopilot
andauthored
Script name casing (#49)
* fix: improve script name handling in JSDocParser - Use the scriptName property verbatim if it exists. - Convert class names to lower camel case when scriptName is not present. - Update attribute extraction to use the original name instead of the lower camel case version. * Update src/index.js Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 63e70ce commit e86071c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,16 @@ export class JSDocParser {
158158
// Check for a static scriptName property and use that as the name if it exists
159159
const scriptNameMember = node.members.find(isScriptNameMember);
160160

161-
// If the scriptName property exists, use that as the name
161+
// If the scriptName property exists, use that verbatim as the name
162+
let finalName;
162163
if (scriptNameMember) {
163-
name = scriptNameMember.initializer.text;
164+
finalName = scriptNameMember.initializer.text;
165+
} else {
166+
// Otherwise, convert the class name to lower camel case
167+
finalName = toLowerCamelCase(name);
164168
}
165169

166-
esmScripts.set(name, node);
170+
esmScripts.set(finalName, node);
167171
}
168172
});
169173

@@ -189,7 +193,7 @@ export class JSDocParser {
189193

190194
// Extract attributes from each script
191195
nodes.forEach((node, name) => {
192-
const opts = results[toLowerCamelCase(name)] = { attributes: {}, errors: [] };
196+
const opts = results[name] = { attributes: {}, errors: [] };
193197
this.parser.extractAttributes(node, opts);
194198
});
195199

0 commit comments

Comments
 (0)