@@ -21,29 +21,10 @@ cleanup() {
2121# Set trap to cleanup on exit
2222trap cleanup EXIT
2323
24- # Color definitions
25- RED=' \033[0;31m'
26- GREEN=' \033[0;32m'
27- YELLOW=' \033[1;33m'
28- BLUE=' \033[0;34m'
29- # No Color
30- NC=' \033[0m'
31-
32- log_info () {
33- echo -e " ${BLUE} [ INFO]${NC} $1 " >&4
34- }
35-
36- log_success () {
37- echo -e " ${GREEN} [ SUCC]${NC} $1 " >&4
38- }
39-
40- log_warning () {
41- echo -e " ${YELLOW} [ WARN]${NC} $1 " >&4
42- }
43-
44- log_error () {
45- echo -e " ${RED} [ERROR]${NC} $1 " >&4
46- }
24+ # Source logging functions
25+ SCRIPT_DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
26+ LOG_FD=4
27+ source " ${SCRIPT_DIR} /lib/log.sh"
4728
4829# Check if command exists
4930check_command () {
@@ -163,43 +144,39 @@ check_firefox_nightly() {
163144build_and_run_extension () {
164145 local device_id=" $1 "
165146 local extension_dir=" dist_dev_firefox"
166-
167147 # Clear existing extension directory
168148 if [ -d " $extension_dir " ]; then
169149 log_info " Clearing existing extension directory..."
170150 rm -rf " $extension_dir "
171151 fi
172-
173152 # Start npm run dev:firefox in background
174153 log_info " Starting npm run dev:firefox in background..."
175154 npm run dev:firefox > /dev/null 2>&1 &
176155 NPM_PID=$!
177-
178156 # Wait for manifest.json to be created
179157 local max_wait=60
180158 local wait_count=0
181159 log_info " Waiting for building finished..."
182-
183160 while [ ! -f " $extension_dir /manifest.json" ] && [ $wait_count -lt $max_wait ]; do
184161 sleep 1
185162 wait_count=$(( wait_count + 1 ))
186163 if [ $(( wait_count % 5 )) -eq 0 ]; then
187164 log_info " Still waiting for building finished... ($wait_count /$max_wait )"
188165 fi
189166 done
190-
167+
191168 if [ ! -f " $extension_dir /manifest.json" ]; then
192169 log_error " Building not finished yet after ${max_wait} s"
193170 cleanup
194171 exit 1
195172 fi
196-
173+
197174 log_success " Extension built successfully, manifest.json found"
198175 log_info " Background build process PID: $NPM_PID "
199176
200177 log_info " Starting extension development server..."
201178 log_info " Command: web-ext run -t firefox-android --firefox-apk org.mozilla.fenix -s $extension_dir --adb-device $device_id --verbose"
202-
179+
203180 if web-ext run \
204181 -t firefox-android \
205182 --firefox-apk org.mozilla.fenix \
0 commit comments