8000 env doesn't append array values to default · Issue #392 · indexzero/nconf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
env doesn't append array values to default #392
Open
@acceleratxr

Description

@acceleratxr

nodejs version: all
nconf version: v0.11.3

Steps to Reproduce

  1. Create an application that uses nconf with env parsing and the following defaults.
const conf = require("nconf")
    .env({
        separator: "__",
        parseValues: true,
    });

conf.defaults({
    myarray: ["value1"]
});
  1. Launch the application with the following environment variable passed in.
myarray__1=value2

Expected Results

The resulting array has two values.

const myarray = conf.get("myarray");
// [
//    0: 'value1',
//    1: 'value2'
// ]

Actual Results

The result is transformed to an object with one value, value2 with key 1. The first value of key 0 is missing and the object is not iterable.

const myarray = conf.get("myarray");
// {
//    1: 'value2'
// }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0