@@ -2,8 +2,8 @@ const { spawn } = require('child_process');
2
2
const fs = require ( 'fs' ) ;
3
3
4
4
// Function to run a shell command and return the process immediately
5
- function runCommand ( command , args = [ ] ) {
6
- const process = spawn ( command , args ) ;
5
+ function runCommand ( command , args = [ ] , options = { } ) {
6
+ const process = spawn ( command , args , options ) ;
7
7
8
8
process . stdout . on ( 'data' , ( data ) => {
9
9
console . log ( data . toString ( ) ) ;
@@ -68,7 +68,7 @@ async function getAndSaveRoutes(port, filePath) {
68
68
69
69
// Main function to run the tasks
70
70
async function main ( ) {
71
- const port = process . env . PORT || 3000 ;
71
+ const port = process . env . PORT || 5000 ;
72
72
if ( ! port ) {
73
73
console . error ( 'Environment variable PORT is not set' ) ;
74
74
process . exit ( 1 ) ;
@@ -85,14 +85,15 @@ async function main() {
85
85
`Waiting for server ${ apiProcess . pid } to be ready on port ${ port } ...` ,
86
86
) ;
87
87
await waitForServer ( port ) ;
88
+ process . env . BASE_URL = `http://localhost:${ port } ` ;
88
89
89
90
console . log ( 'Server is ready. Fetching routes...' ) ;
90
91
await getAndSaveRoutes ( port , 'routes.txt' ) ;
91
92
92
93
console . log ( 'Routes saved to routes.txt' ) ;
93
94
94
95
console . log ( 'Building app...' ) ;
95
- await runCommandAndWait ( 'nx' , [ 'build' , 'app' ] ) ;
96
+ await runCommandAndWait ( `nx` , [ 'build' , 'app' ] ) ;
96
97
console . log ( 'App build completed' ) ;
97
98
98
99
console . log ( 'Stopping server...' ) ;
0 commit comments