Files
Harikrishnan Gopal 5d40065667 Add code to run npm start in both client & server
- Created a `run.js` script to automate the execution of `npm start` in both `client` and `server` directories.
- Added a check for `node_modules` to run `npm install` if missing before starting the applications.
- Updated root `package.json` with `install-all` and `start-all` scripts for easy installation and starting of both client and server simultaneously.
2025-04-15 21:02:58 +05:30

28 lines
861 B
JavaScript

const { spawn } = require('child_process');
const path = require('path');
const fs = require('fs');
const directories = ['client', 'server'];
function runCommand(command, args, cwd) {
const proc = spawn(command, args, { cwd, stdio: 'inherit', shell: true });
proc.on('close', (code) => {
if (code !== 0) {
console.error(`Process in ${cwd} exited with code ${code}`);
}
});
}
directories.forEach(dir => {
const fullPath = path.join(__dirname, dir);
// Check if node_modules exists; if not, run npm install first
if (!fs.existsSync(path.join(fullPath, 'node_modules'))) {
console.log(`node_modules not found in ${dir}. Running npm install...`);
runCommand('npm', ['install'], fullPath);
}
console.log(`Starting npm start in ${dir}`);
runCommand('npm', ['start'], fullPath);
});