All files / src/args getKeyPair.js

100% Statements 12/12
50% Branches 1/2
100% Functions 2/2
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 252x   2x 2x   2x 1x 1x       1x     2x 1x   1x 1x     2x      
const path = require('path')
 
const { getArg } = require('./getArg')
const { KEY_PAIR } = require('./argOptions')
 
const getKeyPairLocation = () => {
  const adminKeysArg = getArg(process.argv, KEY_PAIR)
  const keyPairLocation = adminKeysArg
    ? path.resolve(adminKeysArg)
    : `${process.cwd()}/keyPair.json`
 
  return keyPairLocation
}
 
const getKeyPair = () => {
  const keyPairLocation = getKeyPairLocation()
  // eslint-disable-next-line
  const keyPair = require(keyPairLocation)
  return keyPair
}
 
module.exports = {
  getKeyPair
}