Skip to content

Commit 13575e9

Browse files
committed
Build for release v1.1.1
1 parent 41aa15b commit 13575e9

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

dist/index.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,27 @@ const core = __importStar(__nccwpck_require__(7484));
4545
const exec = __importStar(__nccwpck_require__(5236));
4646
const path = __importStar(__nccwpck_require__(6928));
4747
const fs = __importStar(__nccwpck_require__(9896));
48+
function stripAnsi(input) {
49+
return input.replace(/[\u001B\u009B][[()\]#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
50+
}
51+
function annotateFromOutput(output, workingDirectory) {
52+
const clean = stripAnsi(output);
53+
const re = /^(.+?):(\d+):(\d+)\s+(Error|Warning|Hint):\s+(.*)$/gm;
54+
let match;
55+
while ((match = re.exec(clean))) {
56+
const [, relFile, lineStr, colStr, sev, message] = match;
57+
const filePath = path.normalize(path.join(workingDirectory, relFile));
58+
const line = parseInt(lineStr, 10) || 1;
59+
const col = parseInt(colStr, 10) || 1;
60+
const props = { file: filePath, startLine: line, startColumn: col, title: 'svelte-check' };
61+
if (sev === 'Error')
62+
core.error(message, props);
63+
else if (sev === 'Warning')
64+
core.warning(message, props);
65+
else
66+
core.notice(message, props);
67+
}
68+
}
4869
async function run() {
4970
try {
5071
const workingDirectory = core.getInput('working-directory') || '.';
@@ -54,7 +75,6 @@ async function run() {
5475
const matcherPath = path.join(__dirname, '..', '.github', 'svelte-check-matcher.json');
5576
core.info(`Adding problem matcher: ${matcherPath}`);
5677
console.log(`::add-matcher::${matcherPath}`);
57-
// Detect SvelteKit and run `svelte-kit sync` to ensure .svelte-kit/tsconfig.json exists
5878
let looksLikeSvelteKit = false;
5979
try {
6080
const pkgJsonPath = path.join(workingDirectory, 'package.json');
@@ -100,6 +120,7 @@ async function run() {
100120
};
101121
const exitCode = await exec.exec(npx, args, options);
102122
core.info(`svelte-check exit code: ${exitCode}`);
123+
annotateFromOutput(output + '\n' + errorOutput, workingDirectory);
103124
const errorCount = (output.match(/Error:/g) || []).length;
104125
const warningCount = (output.match(/Warning:/g) || []).length;
105126
const hintCount = (output.match(/Hint:/g) || []).length;
@@ -123,7 +144,6 @@ async function run() {
123144
shouldFail = true;
124145
core.error(`Found ${hintCount} hints (fail-on-hints is enabled)`);
125146
}
126-
// If svelte-check failed for other reasons, surface stderr
127147
if (!shouldFail && exitCode !== 0 && errorOutput.trim()) {
128148
shouldFail = true;
129149
core.error(errorOutput);

0 commit comments

Comments
 (0)