UNPKG

dev-with-debug

Version:

Auto-start Chrome-based dev server with debugging enabled, streaming LLM-friendly error output

47 lines (36 loc) 1.51 kB
#!/usr/bin/env node const fs = require('fs'); const path = require('path'); function addScriptToPackageJson() { try { // Look for package.json in the project root (not this package's root) const projectRoot = process.cwd(); const packageJsonPath = path.join(projectRoot, 'package.json'); if (!fs.existsSync(packageJsonPath)) { console.log('⚠️ No package.json found in project root. Skipping script installation.'); return; } const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); // Initialize scripts object if it doesn't exist if (!packageJson.scripts) { packageJson.scripts = {}; } // Add the dev-with-debug script if it doesn't exist if (!packageJson.scripts['dev-with-debug']) { packageJson.scripts['dev-with-debug'] = 'dev-with-debug'; // Write back to package.json fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n'); console.log('✅ Added "dev-with-debug" script to package.json'); console.log(' You can now run: npm run dev-with-debug'); } else { console.log('ℹ️ "dev-with-debug" script already exists in package.json'); } } catch (error) { console.error('❌ Error adding script to package.json:', error.message); } } // Only run if this is being executed directly (not required as a module) if (require.main === module) { addScriptToPackageJson(); } module.exports = addScriptToPackageJson;