{"size": 618, "ext": "js", "max_stars_repo_path": "repos/args-parse/src/options/checkENVValue.js", "max_stars_repo_name": "keg-hub/keg-cli", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "repos/args-parse/src/options/checkENVValue.js", "max_issues_repo_name": "keg-hub/keg-cli", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "repos/args-parse/src/options/checkENVValue.js", "max_forks_repo_name": "keg-hub/keg-cli", "max_forks_repo_forks_event_min_datetime": "2021-12-02T02:09:11.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-02T02:09:11.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 29.4285714286, "max_line_length": 86, "alphanum_fraction": 0.6682847896}
const { exists } = require('@keg-hub/jsutils')

/**
 * If the option meta-data has an env set, then check if it exists, and use it's value
 * IMPORTANT - If no value exists, and meta.env does exist
 *             It will return meta.env
 * @function
 * @param {string} value - Data passed from cmd line
 * @param {string} metaEnv - Metadata ENV to check for
 *
 * @return {string} - Found value from value param or process.env[metaEnv]
 */
const checkENVValue = (value, metaEnv) => {
  return !exists(value) && exists(process.env[metaEnv])
    ? process.env[metaEnv]
    : value
}

module.exports = {
  checkENVValue
}