File tree Expand file tree Collapse file tree 5 files changed +28
-6
lines changed Expand file tree Collapse file tree 5 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,7 @@ MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/source:/app/source"
150150MOUNT_LIST=" $MOUNT_LIST -v " " $( pwd) " " /dist:/app/dist"
151151MOUNT_LIST=" $MOUNT_LIST -v " " $( pwd) " " /downloads:/app/downloads"
152152MOUNT_LIST=" $MOUNT_LIST -v " " $( pwd) " " /pkgroot:/app/pkgroot"
153+ MOUNT_LIST=" $MOUNT_LIST -v " " $( pwd) " " /log:/app/log"
153154if [ -f " $( pwd) /craft.yml" ]; then
154155 MOUNT_LIST=" $MOUNT_LIST -v " " $( pwd) " " /craft.yml:/app/craft.yml"
155156fi
Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/source:/app/source"
158158MOUNT_LIST=" $MOUNT_LIST -v " " $( pwd) " " /dist:/app/dist"
159159MOUNT_LIST=" $MOUNT_LIST -v " " $( pwd) " " /downloads:/app/downloads"
160160MOUNT_LIST=" $MOUNT_LIST -v " " $( pwd) " " /pkgroot:/app/pkgroot"
161+ MOUNT_LIST=" $MOUNT_LIST -v " " $( pwd) " " /log:/app/log"
161162if [ -f " $( pwd) /craft.yml" ]; then
162163 MOUNT_LIST=" $MOUNT_LIST -v " " $( pwd) " " /craft.yml:/app/craft.yml"
163164fi
Original file line number Diff line number Diff line change @@ -222,11 +222,9 @@ public function handle(): int
222222
223223 // ---------- When using bin/spc-alpine-docker, the build root path is different from the host system ----------
224224 $ build_root_path = BUILD_ROOT_PATH ;
225- $ cwd = getcwd ();
226225 $ fixed = '' ;
226+ $ build_root_path = get_display_path ($ build_root_path );
227227 if (!empty (getenv ('SPC_FIX_DEPLOY_ROOT ' ))) {
228- str_replace ($ cwd , '' , $ build_root_path );
229- $ build_root_path = getenv ('SPC_FIX_DEPLOY_ROOT ' ) . '/ ' . basename ($ build_root_path );
230228 $ fixed = ' (host system) ' ;
231229 }
232230 if (($ rule & BUILD_TARGET_CLI ) === BUILD_TARGET_CLI ) {
Original file line number Diff line number Diff line change @@ -137,13 +137,18 @@ public static function handleSPCException(SPCException $e): void
137137
138138 self ::logError ("\n---------------------------------------- \n" );
139139
140- self ::logError ('⚠ The ' . ConsoleColor::cyan ('console output log ' ) . ConsoleColor::red (' is saved in ' ) . ConsoleColor::none (SPC_OUTPUT_LOG ));
140+ // convert log file path if in docker
141+ $ spc_log_convert = get_display_path (SPC_OUTPUT_LOG );
142+ $ shell_log_convert = get_display_path (SPC_SHELL_LOG );
143+ $ spc_logs_dir_convert = get_display_path (SPC_LOGS_DIR );
144+
145+ self ::logError ('⚠ The ' . ConsoleColor::cyan ('console output log ' ) . ConsoleColor::red (' is saved in ' ) . ConsoleColor::none ($ spc_log_convert ));
141146 if (file_exists (SPC_SHELL_LOG )) {
142- self ::logError ('⚠ The ' . ConsoleColor::cyan ('shell output log ' ) . ConsoleColor::red (' is saved in ' ) . ConsoleColor::none (SPC_SHELL_LOG ));
147+ self ::logError ('⚠ The ' . ConsoleColor::cyan ('shell output log ' ) . ConsoleColor::red (' is saved in ' ) . ConsoleColor::none ($ shell_log_convert ));
143148 }
144149 if ($ e ->getExtraLogFiles () !== []) {
145150 foreach ($ e ->getExtraLogFiles () as $ key => $ file ) {
146- self ::logError ("⚠ Log file [ {$ key }] is saved in: " . ConsoleColor::none (SPC_LOGS_DIR . " / {$ file }" ));
151+ self ::logError ("⚠ Log file [ {$ key }] is saved in: " . ConsoleColor::none ("{ $ spc_logs_dir_convert } / {$ file }" ));
147152 }
148153 }
149154 if (!defined ('DEBUG_MODE ' )) {
Original file line number Diff line number Diff line change @@ -300,3 +300,20 @@ function strip_ansi_colors(string $text): string
300300 // Including color codes, cursor control, clear screen and other control sequences
301301 return preg_replace ('/\e\[[0-9;]*[a-zA-Z]/ ' , '' , $ text );
302302}
303+
304+ /**
305+ * Convert to a real path for display purposes, used in docker volumes.
306+ */
307+ function get_display_path (string $ path ): string
308+ {
309+ $ deploy_root = getenv ('SPC_FIX_DEPLOY_ROOT ' );
310+ if ($ deploy_root === false ) {
311+ return $ path ;
312+ }
313+ $ cwd = WORKING_DIR ;
314+ // replace build root with deploy root, only if path starts with build root
315+ if (str_starts_with ($ path , $ cwd )) {
316+ return $ deploy_root . substr ($ path , strlen ($ cwd ));
317+ }
318+ throw new WrongUsageException ("Cannot convert path: {$ path }" );
319+ }
You can’t perform that action at this time.
0 commit comments