2021-01-13 07:10:33 +01:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const core = require("@actions/core");
|
2021-01-16 05:35:50 +01:00
|
|
|
const {"main": markdownlintCli2} = require("markdownlint-cli2");
|
2021-01-13 07:10:33 +01:00
|
|
|
|
|
|
|
const logMessage = core.info;
|
2022-02-05 21:57:47 +01:00
|
|
|
const logError = (error) => {
|
|
|
|
// eslint-disable-next-line init-declarations
|
|
|
|
let annotation;
|
|
|
|
const match = error.match(/^([^:]+):(\d+)(?::(\d+))?\s(\S+)\s(.+)$/u);
|
|
|
|
if (match) {
|
|
|
|
const [
|
|
|
|
,
|
|
|
|
file,
|
|
|
|
startLine,
|
|
|
|
startColumn,
|
|
|
|
,
|
|
|
|
title
|
|
|
|
] = match;
|
|
|
|
annotation = {
|
|
|
|
title,
|
|
|
|
file,
|
|
|
|
startLine,
|
|
|
|
startColumn
|
|
|
|
};
|
|
|
|
}
|
|
|
|
core.error(error, annotation);
|
|
|
|
};
|
2021-01-16 05:35:50 +01:00
|
|
|
const argv =
|
|
|
|
core.getInput("globs").
|
|
|
|
split("\n").
|
2021-02-21 04:17:39 +01:00
|
|
|
filter((glob) => String(glob));
|
2021-01-13 07:25:46 +01:00
|
|
|
|
2021-01-13 07:10:33 +01:00
|
|
|
markdownlintCli2({
|
2021-01-13 23:50:05 +01:00
|
|
|
argv,
|
2021-01-13 07:10:33 +01:00
|
|
|
logMessage,
|
|
|
|
logError
|
|
|
|
}).then(
|
2021-01-16 05:35:50 +01:00
|
|
|
(code) => code && core.setFailed(`Failed with exit code: ${code}`),
|
|
|
|
(error) => core.setFailed(`Failed due to error: ${error}`)
|
2021-01-13 07:10:33 +01:00
|
|
|
);
|