@@ -2,8 +2,8 @@ const { spawn } = require('child_process');
22const fs = require ( 'fs' ) ;
33
44// 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 ) ;
77
88 process . stdout . on ( 'data' , ( data ) => {
99 console . log ( data . toString ( ) ) ;
@@ -68,7 +68,7 @@ async function getAndSaveRoutes(port, filePath) {
6868
6969// Main function to run the tasks
7070async function main ( ) {
71- const port = process . env . PORT || 3000 ;
71+ const port = process . env . PORT || 5000 ;
7272 if ( ! port ) {
7373 console . error ( 'Environment variable PORT is not set' ) ;
7474 process . exit ( 1 ) ;
@@ -85,14 +85,15 @@ async function main() {
8585 `Waiting for server ${ apiProcess . pid } to be ready on port ${ port } ...` ,
8686 ) ;
8787 await waitForServer ( port ) ;
88+ process . env . BASE_URL = `http://localhost:${ port } ` ;
8889
8990 console . log ( 'Server is ready. Fetching routes...' ) ;
9091 await getAndSaveRoutes ( port , 'routes.txt' ) ;
9192
9293 console . log ( 'Routes saved to routes.txt' ) ;
9394
9495 console . log ( 'Building app...' ) ;
95- await runCommandAndWait ( 'nx' , [ 'build' , 'app' ] ) ;
96+ await runCommandAndWait ( `nx` , [ 'build' , 'app' ] ) ;
9697 console . log ( 'App build completed' ) ;
9798
9899 console . log ( 'Stopping server...' ) ;
0 commit comments