Add market buy option
This commit is contained in:
7
index.js
7
index.js
@@ -6,6 +6,11 @@ const getEnv = (...vars) => vars.map(name => {
|
||||
assert(value, `Provide the ${name} environment variable.`)
|
||||
return value
|
||||
})
|
||||
const getEnvOpt = (varname, defaultValue, allowedValues) => {
|
||||
const value = process.env[varname] || defaultValue
|
||||
if (allowedValues) assert(allowedValues.includes(value), `The ${varname} environment variable must be one of ${allowedValues.map(v => `"${v}"`).join(", ")}.`)
|
||||
return value
|
||||
}
|
||||
const command = process.argv[2].replace('--cmd=', '')
|
||||
const validate = process.argv.includes('--validate') || process.env['KRAKEN_DRY_RUN_PLACE_NO_ORDER']
|
||||
|
||||
@@ -15,7 +20,7 @@ const validate = process.argv.includes('--validate') || process.env['KRAKEN_DRY_
|
||||
const kraken = new Kraken(apiKey, secret)
|
||||
|
||||
const cmd = require(`./commands/${command}`)
|
||||
await cmd(kraken, validate, getEnv)
|
||||
await cmd(kraken, validate, { getEnv, getEnvOpt })
|
||||
|
||||
if (validate) console.log('\n🚨 THIS WAS JUST A VALIDATION RUN!')
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user