UNPKG

1.4 kBJavaScriptView Raw
1"use strict";
2// We use any as a valid input type
3/* eslint-disable @typescript-eslint/no-explicit-any */
4Object.defineProperty(exports, "__esModule", { value: true });
5exports.toCommandProperties = exports.toCommandValue = void 0;
6/**
7 * Sanitizes an input into a string so it can be passed into issueCommand safely
8 * @param input input to sanitize into a string
9 */
10function toCommandValue(input) {
11 if (input === null || input === undefined) {
12 return '';
13 }
14 else if (typeof input === 'string' || input instanceof String) {
15 return input;
16 }
17 return JSON.stringify(input);
18}
19exports.toCommandValue = toCommandValue;
20/**
21 *
22 * @param annotationProperties
23 * @returns The command properties to send with the actual annotation command
24 * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
25 */
26function toCommandProperties(annotationProperties) {
27 if (!Object.keys(annotationProperties).length) {
28 return {};
29 }
30 return {
31 title: annotationProperties.title,
32 file: annotationProperties.file,
33 line: annotationProperties.startLine,
34 endLine: annotationProperties.endLine,
35 col: annotationProperties.startColumn,
36 endColumn: annotationProperties.endColumn
37 };
38}
39exports.toCommandProperties = toCommandProperties;
40//# sourceMappingURL=utils.js.map
\No newline at end of file