#!/usr/bin/env node const { execFileSync } = require('child_process'); const path = require('path'); const file = process.argv[2]; if (!file) { console.error('āŒ Please provide a file path'); process.exit(1); } // Get absolute path const absolutePath = path.resolve(file); try { // Run prettier console.log(`šŸŽØ Formatting ${path.basename(file)}...`); execFileSync('npm', ['run', 'prettier:file', '--', absolutePath], { stdio: 'pipe', encoding: 'utf8', }); // Run lint based on file type console.log(`šŸ” Linting ${path.basename(file)}...`); if (file.endsWith('.scss')) { // Use stylelint for SCSS files execFileSync('npx', ['stylelint', absolutePath], { stdio: 'pipe', encoding: 'utf8', }); } else { // Use ng lint for TypeScript/JavaScript files execFileSync('npm', ['run', 'lint:file', '--', absolutePath], { stdio: 'pipe', encoding: 'utf8', }); } // If we get here, both commands succeeded console.log(`āœ… ${path.basename(file)} - All checks passed!`); } catch (error) { // If there's an error, show the full output console.error('\nāŒ Errors found:\n'); console.error(error.stdout || error.stderr || error.message); process.exit(1); }