From 2b7e28b591a6947f76ddf9a53f49eec8f1accc0f Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Tue, 25 Feb 2020 06:48:14 +1100 Subject: feat: Add Deno.formatDiagnostics (#4032) --- cli/js/format_error.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'cli/js/format_error.ts') diff --git a/cli/js/format_error.ts b/cli/js/format_error.ts index d1d5a73f2..63250473b 100644 --- a/cli/js/format_error.ts +++ b/cli/js/format_error.ts @@ -1,4 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +import { DiagnosticItem } from "./diagnostics.ts"; import * as dispatch from "./dispatch.ts"; import { sendSync } from "./dispatch_json.ts"; @@ -7,3 +8,11 @@ export function formatError(errString: string): string { const res = sendSync(dispatch.OP_FORMAT_ERROR, { error: errString }); return res.error; } + +/** + * Format an array of diagnostic items and return them as a single string. + * @param items An array of diagnostic items to format + */ +export function formatDiagnostics(items: DiagnosticItem[]): string { + return sendSync(dispatch.OP_FORMAT_DIAGNOSTIC, { items }); +} -- cgit v1.2.3