@@ -32,6 +32,7 @@ function cleanString(string)
32
32
let inputFiles = [ ]
33
33
let stripSMTPragmas = false
34
34
let presets = [ ]
35
+ let reportFilePath = undefined
35
36
36
37
for ( let i = 2 ; i < process . argv . length ; ++ i )
37
38
{
@@ -45,10 +46,26 @@ for (let i = 2; i < process.argv.length; ++i)
45
46
presets . push ( process . argv [ i + 1 ] )
46
47
++ i ;
47
48
}
49
+ else if ( process . argv [ i ] === '--report-file' )
50
+ {
51
+ if ( reportFilePath !== undefined )
52
+ throw Error ( "Option --report-file was specified multiple times." )
53
+
54
+ if ( i + 1 === process . argv . length )
55
+ throw Error ( "Option --report-file was used, but no file name given." )
56
+
57
+ reportFilePath = process . argv [ i + 1 ]
58
+ ++ i ;
59
+ }
48
60
else
49
61
inputFiles . push ( process . argv [ i ] )
50
62
}
51
63
64
+ if ( reportFilePath === undefined )
65
+ throw Error ( "Use --report-file option to specify the report file path." )
66
+
67
+ let reportFile = fs . createWriteStream ( reportFilePath , { flags : 'w' } ) ;
68
+
52
69
if ( presets . length === 0 )
53
70
presets = [ 'legacy-no-optimize' , 'legacy-optimize' ]
54
71
@@ -113,8 +130,11 @@ for (const preset of presets)
113
130
Object . keys ( result [ 'contracts' ] ) . length === 0 ||
114
131
Object . keys ( result [ 'contracts' ] ) . every ( file => Object . keys ( result [ 'contracts' ] [ file ] ) . length === 0 )
115
132
)
133
+ {
116
134
// NOTE: do not exit here because this may be run on source which cannot be compiled
117
- console . log ( filename + ': <ERROR>' )
135
+ reportFile . write ( filename + ': <ERROR>\n' )
136
+ process . stdout . write ( 'E' )
137
+ }
118
138
else
119
139
for ( const contractFile in result [ 'contracts' ] )
120
140
for ( const contractName in result [ 'contracts' ] [ contractFile ] )
@@ -123,6 +143,12 @@ for (const preset of presets)
123
143
124
144
let bytecode = '<NO BYTECODE>'
125
145
let metadata = '<NO METADATA>'
146
+ let progressIndicator = '.'
147
+
148
+ if ( 'metadata' in contractResults && cleanString ( contractResults . metadata ) !== undefined )
149
+ metadata = contractResults . metadata
150
+ else
151
+ progressIndicator = 'M'
126
152
127
153
if (
128
154
'evm' in contractResults &&
@@ -131,12 +157,12 @@ for (const preset of presets)
131
157
cleanString ( contractResults . evm . bytecode . object ) !== undefined
132
158
)
133
159
bytecode = cleanString ( contractResults . evm . bytecode . object )
160
+ else
161
+ progressIndicator = 'B'
134
162
135
- if ( 'metadata' in contractResults && cleanString ( contractResults . metadata ) !== undefined )
136
- metadata = contractResults . metadata
137
-
138
- console . log ( filename + ':' + contractName + ' ' + bytecode )
139
- console . log ( filename + ':' + contractName + ' ' + metadata )
163
+ reportFile . write ( filename + ':' + contractName + ' ' + bytecode + '\n' )
164
+ reportFile . write ( filename + ':' + contractName + ' ' + metadata + '\n' )
165
+ process . stdout . write ( progressIndicator )
140
166
}
141
167
}
142
168
}
0 commit comments