Skip to content

Commit

Permalink
Keep file contents when copying class definition if "Class" line not …
Browse files Browse the repository at this point in the history
…found (#1267)
  • Loading branch information
isc-bsaviano authored Nov 2, 2023
1 parent 231bcfb commit 14a24ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/providers/FileSystemProvider/FileSystemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,19 @@ export function generateFileContent(
// Replace that with one to match fileName.
while (sourceLines.length > 0) {
const nextLine = sourceLines.shift();
if (nextLine.startsWith("Class ")) {
if (nextLine.toLowerCase().startsWith("class ")) {
const classLine = nextLine.split(" ");
classLine[0] = "Class";
classLine[1] = className;
content.push(...preamble, classLine.join(" "), ...sourceLines);
break;
}
preamble.push(nextLine);
}
if (!content.length) {
// Transfer sourceLines verbatim in cases where no class header line is found
content.push(...preamble);
}
}
} else {
content = [`Class ${className} Extends %RegisteredObject`, "{", "}"];
Expand Down

0 comments on commit 14a24ab

Please sign in to comment.