-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-yaml.js
More file actions
30 lines (26 loc) · 850 Bytes
/
check-yaml.js
File metadata and controls
30 lines (26 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const fs = require('fs');
const content = fs.readFileSync('d:\\Automerge.Windows\\.github\\workflows\\release.yml', 'utf8');
const lines = content.split('\n');
let issues = 0;
// Check for tabs
lines.forEach((l, i) => {
if (l.includes('\t')) {
console.log('TAB at line', i+1, JSON.stringify(l.slice(0, 80)));
issues++;
}
});
// Check for BOM
if (content.charCodeAt(0) === 0xFEFF) {
console.log('BOM detected at start of file!');
issues++;
}
// Check for non-ASCII
let nonAscii = 0;
for (let i = 0; i < content.length; i++) {
if (content.charCodeAt(i) > 127) nonAscii++;
}
console.log('Non-ASCII chars:', nonAscii);
console.log('Has BOM:', content.charCodeAt(0) === 0xFEFF);
console.log('Total issues:', issues);
console.log('Total lines:', lines.length);
console.log('File size (bytes):', Buffer.byteLength(content, 'utf8'));