2024-03-08 16:55:46 +01:00
|
|
|
import path from 'path';
|
|
|
|
|
import fs from 'fs';
|
|
|
|
|
import process from 'process';
|
2024-01-07 17:15:49 +01:00
|
|
|
import { spawn } from 'child_process';
|
|
|
|
|
|
|
|
|
|
const regex = /(?<file>[^:]+):(?<line>\d+):(?<column>\d+)\s-\s+(?<message>.+)/;
|
2024-03-08 16:55:46 +01:00
|
|
|
const fileList = process.env.CHANGED_FILES
|
|
|
|
|
? (process.env.CHANGED_FILES || '').split(' ')
|
|
|
|
|
: fs.readdirSync('./icons').map((fileName) => path.join('./icons', fileName));
|
2024-01-07 17:15:49 +01:00
|
|
|
|
|
|
|
|
const cspell = spawn('npx', ['cspell', 'stdin'], { stdio: ['pipe', 'pipe', 'inherit'] });
|
|
|
|
|
cspell.stdin.write(fileList.join('\n'));
|
|
|
|
|
cspell.stdin.end();
|
|
|
|
|
|
|
|
|
|
cspell.stdout.on('data', (data) => {
|
|
|
|
|
console.log(data.toString());
|
|
|
|
|
data
|
|
|
|
|
.toString()
|
|
|
|
|
.split('\n')
|
2025-06-18 15:47:24 +02:00
|
|
|
.forEach((line: string) => {
|
2024-01-07 17:15:49 +01:00
|
|
|
const match = line.match(regex);
|
|
|
|
|
if (match) {
|
2025-06-18 15:47:24 +02:00
|
|
|
const { line, message } = match.groups ?? {};
|
|
|
|
|
console.log(`::error file=${fileList[Number(line) - 1]},line=1,column=1::${message}`);
|
2024-01-07 17:15:49 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
cspell.on('exit', process.exit);
|