@@ -12,11 +12,12 @@ VERBOSE = false
12
12
13
13
try
14
14
if process .argv .length < 3
15
- throw new Error " No file specified"
15
+ console .error JSON .stringify {errors : [{id : " INVALID" }]}
16
+ process .exit 1
16
17
filename = process .argv [2 ]
17
18
script = fs .readFileSync filename, ' utf8'
18
19
catch e
19
- console .log " File could not be read "
20
+ console .error JSON . stringify { errors : [{ id : " NOTFOUND " }]}
20
21
process .exit 1
21
22
22
23
details = null
@@ -28,7 +29,7 @@ script = script.replace re, (header) ->
28
29
details = JSON .parse matches[1 ]
29
30
return " "
30
31
unless details?
31
- console .error " There are no details! "
32
+ console .error JSON . stringify { errors : [{ id : " NOHEADER " }]}
32
33
process .exit 1
33
34
34
35
details .id = 2
@@ -225,8 +226,9 @@ walk = (ast) ->
225
226
]
226
227
]
227
228
else
228
- console .error " Unknown type: '#{ type} '"
229
- console .error util .inspect ast, false , null , true
229
+ if VERBOSE
230
+ console .error " Unknown type: '#{ type} '"
231
+ console .error util .inspect ast, false , null , true
230
232
return ast
231
233
ast = parser .parse script
232
234
if VERBOSE
@@ -264,9 +266,20 @@ ok = JSLINT script, {
264
266
plugin : false
265
267
}
266
268
unless ok
267
- console .error " FAIL"
268
269
result = JSLINT .data ()
269
- console .error util .inspect result, false , 3 , true
270
+ if VERBOSE
271
+ console .error util .inspect result, false , 3 , true
272
+ else
273
+ out = {errors : []}
274
+ for error in result .errors
275
+ out .errors .push
276
+ raw : error .raw
277
+ reason : error .reason
278
+ line : error .line
279
+ character : error .character
280
+ evidence : error .evidence
281
+ console .error JSON .stringify out
282
+ process .exit 1
270
283
else
271
284
script = script .substr (head .length , script .length - (head .length + foot .length ))
272
285
script = " new ADSAFE_APP(#{ id} , \" #{ adsafeId} \" , #{ JSON .stringify (details)} , function(ADSAFE){\n #{ script} \n });"
0 commit comments