UNPKG

js-error-finder

Version:

A utility to find syntax errors in JavaScript files.

27 lines (21 loc) 631 B
#!/usr/bin/env node const findJsErrors = require('./index'); const path = require('path'); // Get file path from command line arguments const filePath = process.argv[2]; if (!filePath) { console.error('Error: Please provide a file path.'); process.exit(1); } // Resolve file path and validate const absolutePath = path.resolve(filePath); const result = findJsErrors(absolutePath); if (result.valid) { console.log('No errors found! The file is valid.'); } else { console.error('Errors found:'); result.errors.forEach((error) => { console.error(`- ${error.message}`); console.error(` ${error.hint}`); }); }