Skip to content

Commit 571e5e7

Browse files
committed
feat : add bash script to generate used ports
1 parent 5a8fa85 commit 571e5e7

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/BeAPI/beapi-frontend-framework"
88
},
99
"scripts": {
10-
"start": "node_modules/.bin/concurrently -k -n \"Webpack,PHP Server\" -p \"[{name}]\" -c \"green, blue\" \"node_modules/.bin/webpack --mode=development --watch\" \"php -S localhost:9090\"",
10+
"start": "node_modules/.bin/concurrently -k -n \"Webpack,PHP Server\" -p \"[{name}]\" -c \"green, blue\" \"node_modules/.bin/webpack --mode=development --watch\" \"sh server.sh\"",
1111
"build:dev": "node_modules/.bin/webpack --mode=development && npm run icon && npm run favicon",
1212
"build:prod": "npm run clean && node_modules/.bin/webpack --mode=production && npm run icon && npm run favicon",
1313
"build": "npm run clean && node_modules/.bin/webpack --mode=production && npm run build:dev",

server.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
PORT=9090
3+
BSPORT=3000
4+
5+
while [ -n "$(lsof -Pi :${PORT} -sTCP:LISTEN -t)" ]; do
6+
((PORT++))
7+
done
8+
9+
while [ -n "$(lsof -Pi :${BSPORT} -sTCP:LISTEN -t)" ]; do
10+
((BSPORT += 2))
11+
done
12+
13+
echo "BS will run on port ${BSPORT}"
14+
15+
echo $PORT > ".port"
16+
echo $BSPORT > ".bs-port"
17+
18+
echo "Server is running on port ${PORT} and BrowserSync on port ${BSPORT}"
19+
php -S localhost:${PORT}

0 commit comments

Comments
 (0)