@ansospace/sysmon
Version:
A zero-dependency system monitoring CLI tool for listing system info, real-time monitoring, and cleanup tasks.
49 lines (41 loc) ⢠1.17 kB
JavaScript
import { readFileSync } from 'fs';
const maxLine = 500;
function countExecutableLines(filePath) {
const content = readFileSync(filePath, 'utf8');
const lines = content.split('\n');
let count = 0;
let inMultilineComment = false;
for (let line of lines) {
const trimmed = line.trim();
// Handle multiline comments
if (trimmed.startsWith('/*')) {
inMultilineComment = true;
}
if (trimmed.endsWith('*/')) {
inMultilineComment = false;
continue;
}
if (inMultilineComment) {
continue;
}
// Skip empty lines and comments
if (trimmed === '' || trimmed.startsWith('//')) {
continue;
}
count++;
}
return count;
}
const lineCount = countExecutableLines('./bin/cli.js');
console.log(`\nš Line Count: ${lineCount} / ${maxLine}`);
if (lineCount === maxLine) {
console.log(`ā
Perfect! Exactly ${maxLine} lines.\n`);
process.exit(0);
} else if (lineCount < maxLine) {
console.log(`ā ļø Under limit by ${maxLine - lineCount} lines.\n`);
process.exit(0);
} else {
console.log(`ā Over limit by ${lineCount - maxLine} lines!\n`);
process.exit(1);
}