JSON candidates are wrapped in parentheses
wolfgang42 opened this issue · comments
Wolfgang Faust commented
When jsdelta
is passed a JSON file, it outputs candidate files (delta_js_1.json
and so on) with the JSON wrapped in parentheses, like so:
({"foo": "bar"});
This means that the file is not valid JSON, so trying to delta JSON files doesn't work properly.
I don't know enough about esprima to be able to immediately identify why it's doing this and how to stop it. For my test script I have worked around this by stripping the characters out with the following ugly hack:
if grep '^({' $1 > /dev/null ; then
cat $1 | head -c-2 | tail -c+2 > $TMPDIR/npm-shrinkwrap.json
else
cp $1 $TMPDIR/npm-shrinkwrap.json
fi
Max Schaefer commented
Hm, yes, that's unfortunate.
#19 hopefully fixes it.
Manu Sridharan commented
I've merged #19 so I'll close this issue. I'll also push a new release of jsdelta to npm soon. @wolfgang42 let us know if you still have issues.