You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
621 B

  1. 'use strict'
  2. const _ = require('lodash')
  3. const isoDurationReg = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/
  4. module.exports = {
  5. /**
  6. * Parse configuration value for environment vars
  7. *
  8. * @param {any} cfg Configuration value
  9. * @returns Parse configuration value
  10. */
  11. parseConfigValue (cfg) {
  12. return _.replace(
  13. cfg,
  14. /\$\(([A-Z0-9_]+)\)/g,
  15. (fm, m) => { return process.env[m] }
  16. )
  17. },
  18. isValidDurationString (val) {
  19. return isoDurationReg.test(val)
  20. }
  21. }