@@ -84,10 +84,12 @@ def exec_command(cmd, args):
84
84
if not args :
85
85
args = []
86
86
87
+ print_command ('.' , cmd , args )
88
+
87
89
exitcode = subprocess .call ([cmd ] + args )
88
90
89
91
if exitcode != 0 :
90
- print ('[Failed - %s] %s %s' , exitcode , cmd , ' ' .join (args ))
92
+ print ('[Failed - %s] %s %s' % ( exitcode , cmd , ' ' .join (args ) ))
91
93
exit (1 )
92
94
93
95
@@ -99,6 +101,28 @@ def exec_docker(cmd):
99
101
exec_command ('docker' , ['exec' , '-it' , DOCKER_NAME , '/bin/bash' , '-c' , exec_cmd ])
100
102
101
103
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
+
102
126
def main ():
103
127
option = parse_option ()
104
128
0 commit comments