-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-dev.js
More file actions
31 lines (27 loc) · 998 Bytes
/
start-dev.js
File metadata and controls
31 lines (27 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { spawn } from 'child_process';
function runCommand(command) {
return new Promise((resolve, reject) => {
const [cmd, ...args] = command.split(/\s+/); // Split the command string into command and arguments
const process = spawn(cmd, args, { stdio: 'inherit' }); // Use 'inherit' to display output in the parent's stdio
process.on('close', (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`Command "${command}" failed with exit code ${code}`));
}
});
});
}
async function startDev() {
try {
// Build the project
console.log('Building the project...');
await runCommand('yarn run build');
// Start the Nest application
console.log('Starting the application...');
await runCommand('yarn run start:prod');
} catch (error) {
console.error('Failed to start the application:', error);
}
}
startDev();