|
171 | 171 | } |
172 | 172 | }))).filter((mod) => mod !== undefined); |
173 | 173 | // Sort by Friendly Name |
| 174 | + // TODO Once we upgrade to Typescript 5.5 we don't need the non-null assertion operators https://stackoverflow.com/a/78681671 |
174 | 175 | modList.sort((a, b) => { |
175 | | - const x = a.friendlyName.toLowerCase(); |
176 | | - const y = b.friendlyName.toLowerCase(); |
| 176 | + const x = a!.friendlyName.toLowerCase(); |
| 177 | + const y = b!.friendlyName.toLowerCase(); |
177 | 178 | return x.localeCompare(y); |
178 | 179 | }); |
179 | 180 | // Get max lengths to use for padding |
180 | | - const maxFriendlyNameLen = Math.max(...modList.map((mod) => mod.friendlyName.length)); |
181 | | - const maxModReferenceLen = Math.max(...modList.map((mod) => mod.modReference.length)); |
| 181 | + const maxFriendlyNameLen = Math.max(...modList.map((mod) => mod!.friendlyName.length)); |
| 182 | + const maxModReferenceLen = Math.max(...modList.map((mod) => mod!.modReference.length)); |
182 | 183 | // Create header and add all mods to string |
183 | 184 | let modListString = `${'Mod Name'.padEnd(maxFriendlyNameLen + 1) + 'Mod Reference'.padEnd(maxModReferenceLen + 1)}Version\n`; |
184 | 185 | modList.forEach((mod) => { |
185 | | - mod.friendlyName = mod.friendlyName.padEnd(maxFriendlyNameLen, ' '); |
186 | | - mod.modReference = mod.modReference.padEnd(maxModReferenceLen, ' '); |
187 | | - modListString += `${mod.friendlyName} ${mod.modReference} ${mod.version}\n`; |
| 186 | + mod!.friendlyName = mod!.friendlyName.padEnd(maxFriendlyNameLen, ' '); |
| 187 | + mod!.modReference = mod!.modReference.padEnd(maxModReferenceLen, ' '); |
| 188 | + modListString += `${mod!.friendlyName} ${mod!.modReference} ${mod!.version}\n`; |
188 | 189 | }); |
189 | 190 | const markdownCodeblockFence = '```'; |
190 | 191 | navigator.clipboard.writeText(`${markdownCodeblockFence}\n${modListString.trim()}\n${markdownCodeblockFence}`); |
|
196 | 197 | } |
197 | 198 |
|
198 | 199 | // appease svelte "stores must be declared at the top of the file" |
199 | | - function displayError(err: unknown) { |
| 200 | + function displayError(err: string) { |
200 | 201 | $error = err; |
201 | 202 | } |
202 | 203 |
|
|
0 commit comments