@@ -84,10 +84,12 @@ def exec_command(cmd, args):
8484 if not args :
8585 args = []
8686
87+ print_command ('.' , cmd , args )
88+
8789 exitcode = subprocess .call ([cmd ] + args )
8890
8991 if exitcode != 0 :
90- print ('[Failed - %s] %s %s' , exitcode , cmd , ' ' .join (args ))
92+ print ('[Failed - %s] %s %s' % ( exitcode , cmd , ' ' .join (args ) ))
9193 exit (1 )
9294
9395
@@ -99,6 +101,28 @@ def exec_docker(cmd):
99101 exec_command ('docker' , ['exec' , '-it' , DOCKER_NAME , '/bin/bash' , '-c' , exec_cmd ])
100102
101103
104+ def print_command (cwd , cmd , args ):
105+ '''
106+ Helper function to print commands.
107+ '''
108+ terminal_empty = '\033 [0m'
109+ terminal_green = '\033 [1;32m'
110+ terminal_yellow = '\033 [1;33m'
111+
112+ rpath = os .path .relpath (cwd , DOCKER_JSREMOTE_PATH )
113+ # Resolve the current folder character to the appropriate folder name.
114+ if rpath == os .curdir :
115+ rpath = os .path .basename (os .path .abspath (os .curdir ))
116+
117+ cmd_info = [
118+ '%s[%s]' % (terminal_yellow , rpath ),
119+ '%s%s' % (terminal_green , cmd ),
120+ '%s%s' % (terminal_empty , ' ' .join (args ))
121+ ]
122+
123+ print (' ' .join (cmd_info ))
124+
125+
102126def main ():
103127 option = parse_option ()
104128
0 commit comments