Skip to content

Commit 088ee3d

Browse files
committed
Make output more consistent, add another okayReason.
1 parent 6b75ad5 commit 088ee3d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/pimscript.coffee

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ if tty.isatty(process.stdout.fd)
1414
VERBOSE = true
1515

1616
if process.argv.length < 4
17-
console.error JSON.stringify {errors:[{id:"NOARGS"}]}
17+
console.error JSON.stringify {errors:[{raw:"NOARGS"}]}
1818
process.exit 1
1919

2020
try
2121
filename = process.argv[2]
2222
script = fs.readFileSync filename, 'utf8'
2323
catch e
24-
console.error JSON.stringify {errors:[{id:"NOTFOUND"}]}
24+
console.error JSON.stringify {errors:[{raw:"NOTFOUND"}]}
2525
process.exit 1
2626

2727
try
2828
overrideDetails = JSON.parse process.argv[3]
2929
catch e
30-
console.error JSON.stringify {errors:[{id:"INVALIDJSON"}]}
30+
console.error JSON.stringify {errors:[{raw:"INVALIDJSON"}]}
3131
process.exit 1
3232

3333
if process.argv.length > 4
@@ -47,7 +47,7 @@ script = script.replace re, (header) ->
4747
details = JSON.parse matches[1]
4848
return ""
4949
unless details?
50-
console.error JSON.stringify {errors:[{id:"NOHEADER"}]}
50+
console.error JSON.stringify {errors:[{raw:"NOHEADER"}]}
5151
process.exit 1
5252
lines2 = script.split("\n").length
5353
lineDiff = lines2 - lines
@@ -57,7 +57,7 @@ for k,v of overrideDetails
5757

5858
id = parseInt details.id
5959
if isNaN(id) or !isFinite(id)
60-
console.error JSON.stringify {errors:[{id:"IDNAN"}]}
60+
console.error JSON.stringify {errors:[{raw:"IDNAN"}]}
6161
process.exit 1
6262

6363
# Alias dependencies.
@@ -275,7 +275,7 @@ walk = (ast) ->
275275
try
276276
ast = parser.parse script
277277
catch e
278-
console.error JSON.stringify {errors:[{id:"PARSEFAIL",message:e.message,line:e.line-lineDiff,col:e.col}]}
278+
console.error JSON.stringify {errors:[{raw:"PARSEFAIL",reason:e.message,line:e.line-lineDiff,col:e.col}]}
279279
if VERBOSE
280280
console.log util.inspect e, false, null, true
281281
process.exit 1
@@ -327,7 +327,11 @@ unless ok
327327
line:error.line
328328
character:error.character
329329
evidence:error.evidence
330-
if entry.reason is "Confusing use of '!'."
330+
okayReasons = [
331+
"Confusing use of '!'."
332+
"Expected 'String' and instead saw ''''."
333+
]
334+
if okayReasons.indexOf(entry.reason) isnt -1
331335
out.warnings.push entry
332336
else
333337
out.errors.push entry

0 commit comments

Comments
 (0)