Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 1.57 KB

README.md

File metadata and controls

53 lines (38 loc) · 1.57 KB

C++ Implementation of dotenv NPM Package

This is an attempt to replicate the exact parsing behavior of the dotenv npm package in C++. It only implements the parser of the dotenv package, not of the dotenv-expand package, which would add variable substitution.

In particular this is (or attempts to be) compatible with this version of main.js.

This was written so it maybe could be included in NodeJS as a better compatible version of the dotenv parser. See this issue for context.

Compile and run a test that compares the output of the JavaScript dotenv implementation with this one:

make test

Only compile debug build:

make

Produces the file: target/debug/dotenv

Release build:

make BUILD_TYPE=release

Produces the file: target/release/dotenv

This includes a simple starter program. Usage:

usage: ./build/debug/dotenv [--file=PATH] [--replace] [--overwrite] [--] [command args...]

Positional arguments:
    command    The command to run.
               If no command is provided the constructed environment will be printed.
    args...    Arguments to the command.

Options:
    -f, --file=PATH    Use this file instead of ".env".
    -r, --replace      Construct an entirely new environment.
    -o, --overwrite    Overwrite already defined environment variables.
    -0, --print0       If the environment is printed use NUL bytes instead of new lines.