Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Generate diagnostics without a leading comma, reatain space
  • Loading branch information
weswigham committed Jul 31, 2017
commit ca93e3342ed4b4d10820e7b37ffd064c33e8e6b2
15 changes: 3 additions & 12 deletions scripts/processDiagnosticMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,13 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable): string

function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable): string {
let result = '{';
let first = true;
messageTable.forEach(({ code }, name) => {
if (!first) {
first = false;
}
else {
result += ',';
}

const propName = convertPropertyName(name);
result += `\r\n "${createKey(propName, code)}": "${name.replace(/[\"]/g, '\\"')}"`;
result += `\r\n "${createKey(propName, code)}" : "${name.replace(/[\"]/g, '\\"')}",`;
});

result += '\r\n}';

return result;
// Shave trailing comma, then add newline and ending brace
return result.slice(0, result.length - 1) + '\r\n}';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could messageTable have zero elements at this point? I think the shaving of the comma would be wrong then.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if we have zero diagnostics. Which we should never have. Or minimally we shouldn't still be generating this file if we do not.

}

function createKey(name: string, code: number) : string {
Expand Down