File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "PHP_BIN" : " C:/Users/Saro/Desktop/Applicazioni PHP Desktop/phpapp/php74/php.exe" ,
3
+ "PHP_INI_PATH" : " C:/Users/Saro/Desktop/Applicazioni PHP Desktop/phpapp/php74/php.ini" ,
4
+ "PORT" : 8000
5
+ }
Original file line number Diff line number Diff line change
1
+ const path = require ( 'path' ) ;
2
+ const fs = require ( 'fs' ) ;
3
+ const concurrently = require ( 'concurrently' ) ;
4
+
5
+ const configPath = path . resolve ( __dirname , 'config.json' ) ;
6
+
7
+ if ( ! fs . existsSync ( configPath ) ) {
8
+ console . error ( 'File config.json non trovato!' ) ;
9
+ process . exit ( 1 ) ;
10
+ }
11
+
12
+ const config = JSON . parse ( fs . readFileSync ( configPath , 'utf8' ) ) ;
13
+ const { PHP_BIN , PHP_INI_PATH , PORT } = config ;
14
+
15
+ if ( ! PHP_BIN || ! PHP_INI_PATH || ! PORT ) {
16
+ console . error ( 'Variabili mancanti in config.json' ) ;
17
+ process . exit ( 1 ) ;
18
+ }
19
+
20
+ const phpCmd = `"${ PHP_BIN } " -c "${ PHP_INI_PATH } " -S localhost:${ PORT } route.php` ;
21
+ // const bsCmd = `npx browser-sync start --proxy "localhost:${PORT}" --files "public/**/*" "src/**/*" --no-ui --no-open`;
22
+ // const bsCmd = `npx browser-sync start --proxy "localhost:${PORT}" --files "**/*" --no-ui --open`;
23
+ const bsCmd = `npx browser-sync start --config .bs-config.js` ;
24
+
25
+ concurrently ( [
26
+ { command : phpCmd , name : 'php' , prefixColor : 'blue' } ,
27
+ { command : bsCmd , name : 'bs' , prefixColor : 'magenta' }
28
+ ] , {
29
+ killOthers : [ 'failure' , 'success' ] ,
30
+ restartTries : 0
31
+ } ) . result . then ( ( ) => {
32
+ console . log ( 'Tutti i processi terminati con successo' ) ;
33
+ } ) . catch ( err => {
34
+ console . error ( 'Errore in uno dei processi:' , err ) ;
35
+ } ) ;
You can’t perform that action at this time.
0 commit comments