Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 599 Bytes

v3.0.0.md

File metadata and controls

21 lines (16 loc) · 599 Bytes

v2.0.0 Migration Guide

This version reverts the functionality where figaro-js casts values to primitives. In this version, figaro-js will read all values as strings. In order to emulate the former functionality, you can use a function to do it manually:

const Figaro = require('figaro-js')
const { mapValues } = require('lodash')

// Converts strings to primitive values if possible
// Eg '5' -> 5, 'true' -> true, 'string' -> 'string'

function coerce(str) {
  try {
    return JSON.parse(str)
  } catch (e) {
    return str
  }
}

const myEnv = mapValues(Figaro.read(), coerce)