• Parse a File into an Object using basic env syntax

    This parses line by line so an invalid line will just be skipped

    Type Parameters

    • Options extends {
          async?: boolean;
      }

    Parameters

    • file: PathLike
    • Optional options: Options

    Returns Options["async"] extends false
        ? Record<string, string>
        : Promise<Record<string, string>>

    Example

    import { filesystem } from "@rjweb/utils"

    filesystem.env('./.env') // {K:'12'}
    filesystem.env('./.env.prod') // {E:'400'}
    filesystem.env('./invalid-env') // {}

    Since

    1.10.4

    Supports

    nodejs