Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (args.length === 1 && (args[0] === '-v' || args[0] === '--version')) {
stderr.write(require('./package.json').version + '\n')
process.exit(2)
}
if (args.length === 1 && args[0] === '--life') {
require('./bang')
return
}
input = fs.readFileSync(args[0]).toString('utf8')
filename = path.basename(args[0])
global.FX_FILENAME = filename
args.shift()
}
const json = JSON.parse(input)
if (args.length === 0 && stdout.isTTY) {
require('./fx')(filename, json)
return
}
apply(json)
}
}).then((response) => {
let body = lossless_json.parse(response.body, this._lossless_converter);
if (body.returnCode && body.returnCode == "0000"){
debug(`Completed confirming payment.`);
debug(body);
return body;
} else {
debug(`Failed to confirm payment.`);
debug(body);
return Promise.reject(new Error(body));
}
})
}
const parse = (str, configs) => {
let result
try {
result = _.get(configs, 'options.support-big-int')
? LosslessJSON.parse(str, _reviver)
: JSON.parse(str)
} catch (e) {
throw new Error(`failed to parse json (message: "${e.message}") - source: ${JSON.stringify(str)}`)
}
return result
}
function apply(cb, input) {
let json
try {
json = JSON.parse(input)
} catch (e) {
process.stderr.write(e.toString() + '\n')
return
}
cb(json)
}