100% code coverage with small changes

This commit is contained in:
pavantejapotnuru
2018-10-01 11:47:43 +05:30
parent d5a87708e0
commit 3d607678ff
4 changed files with 48 additions and 18 deletions

View File

@@ -13,16 +13,21 @@ module.exports = {
return convert(input.data, options, cb);
}
else if (input.type === 'file') {
return fs.read(input.data, function(err, data) {
return fs.readFile(input.data, 'utf8', function(err, data) {
if (err) {
return cb(err);
}
return convert(data, options, cb);
try {
return convert(JSON.parse(data), options, cb);
}
catch (e) {
return convert(data, options, cb);
}
});
}
return cb(null, {
result: false,
reason: 'input type is not valid'
reason: 'input type:' + input.type + ' is not valid'
});
}
catch (e) {