Env
Add, edit, delete and read variables from a .env file.
Installation
npm i @marknotton/env --save-dev
const env = require('@marknotton/env');
Data functions
Get File [string]
Get the .env file contents as a string
env.getFile()
First parameter can be the path to your .env file relative to the gulpfile.js
Get Data [object]
Get the .env file content with all the variables and values passed into an object
env.getData()
First parameter can be a direct request for a variable.
Second parameter can be the path to your .env file relative to the gulpfile.js
Get & Set functions
Set Variable
Add a variable and value to the .env file. Variable will be created if it isn't found. It will be overwritten if it does exists.
env.setVariable(variable, value)
Delete Variable [string]
Delete variable from .env file.
env.deleteVariable(variable)
Toggle Variable [string]
Add a 'true' boolean to the given vairable, or remove it entirely if it's false.
env.toggleBooleanVariable(variable, true)
env.toggleBooleanVariable(variable, false)
Get Variable [string]
Get variable from .env file.
env.getVariable(variable)
Has Variable [bool]
Check if a variable exists.
env.hasVariable(variable)