Skip to content

Commit 118988b

Browse files
committed
feat(server): fix internal app dev server
run init command in the background to avoid waits and locks
1 parent 133d906 commit 118988b

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

bin/server.sh

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,16 @@ function initialize_target_project {
149149
fi
150150

151151
(
152-
cd ${project_dir} >/dev/null 2>&1
152+
cd ${project_dir}
153153

154-
# install dependencies
154+
log "installing the output project's npm dependencies..."
155155
npm i >/dev/null 2>&1
156-
if (( $? == 1 )); then
157-
quit "failed installing the output project's npm dependencies"
158-
fi
156+
status_log "installed ok" "install failed"
159157

160-
# launch dev server / whatever
161158
if is_npm_command_available "$init_command"; then
162-
npm run "$init_command" >/dev/null 2>&1
163-
if (( $? == 1 )); then
164-
quit "the output project's initialize command execution failed"
165-
fi
159+
log "executing the output project's npm command '$init_command' in the background..."
160+
npm run "$init_command" &
161+
status_log "executed ok" "execution failed"
166162
fi
167163
)
168164
}
@@ -309,6 +305,17 @@ function log {
309305
printf "\n[dev-server] %s\n" "$msg"
310306
}
311307

308+
function status_log {
309+
local status=$?
310+
local ok_msg="$1"
311+
local err_msg="$2"
312+
if (( $status == 0 )); then
313+
log "$ok_msg"
314+
else
315+
quit "$err_msg"
316+
fi
317+
}
318+
312319
function quit {
313320
local errMsg="$1"
314321
if [[ -n "$errMsg" ]]; then

0 commit comments

Comments
 (0)