* Execute a command in a specific directory * @param {string} command - The command to execute * @param {string} workingDir - The working directory * @param {string} stepName - Name of the step for logging
(command, workingDir, stepName)
| 40 | * @param {string} stepName - Name of the step for logging |
| 41 | */ |
| 42 | function executeStep(command, workingDir, stepName) { |
| 43 | console.log(`\n🔄 ${stepName}`); |
| 44 | console.log(`Working directory: ${workingDir}`); |
| 45 | console.log(`Command: ${command}`); |
| 46 | |
| 47 | // Check if directory exists |
| 48 | if (!fs.existsSync(workingDir)) { |
| 49 | console.error(`❌ Error: Directory ${workingDir} does not exist`); |
| 50 | process.exit(1); |
| 51 | } |
| 52 | |
| 53 | try { |
| 54 | execSync(command, { |
| 55 | cwd: workingDir, |
| 56 | stdio: 'inherit', // This will show the output in real-time |
| 57 | encoding: 'utf8' |
| 58 | }); |
| 59 | console.log(`✅ ${stepName} completed successfully`); |
| 60 | } catch (error) { |
| 61 | console.error(`❌ ${stepName} failed with error:`); |
| 62 | console.error(error.message); |
| 63 | process.exit(1); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | async function main() { |
| 68 | console.log('Setting up developer environment ...'); |