🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

varz

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

varz

Executes a command using the environment variables in an package.json config file

unpublished
latest
Source
npmnpm
Version
11.0.0
Version published
Maintainers
1
Created
Source

varz

A fork of env-cmd with diffrent defaults

A simple node program for executing commands using a package.json config.

đź’ľ Install

npm install varz or npm install -g varz

⌨️ Basic Usage

Package.json

{
  "config": {
    "varz": {
      "dev": {
        "ENV1": "THANKS",
        "ENV2": "FOR ALL",
        "ENV3": "THE FISH"
      }
    }
  },
  "scripts": {
    "test": "varz -e dev \"mocha -R spec\""
  }
}

📜 Help

Usage: _ [options] <command> [...args]

Options:
  -v, --version                       output the version number
  -e, --environments [env1,env2,...]  The rc file environment(s) to use
  -f, --file [path]                   Custom env file path (default path: ./.env)
  --fallback                          Fallback to default env file path, if custom env file path not found
  --no-override                       Do not override existing environment variables
  -r, --rc-file [path]                Custom rc file path (default path: ./.varzrc(|.js|.json)
  --silent                            Ignore any varz errors and only fail on executed program failure.
  --use-shell                         Execute the command in a new shell with the given environment (true by default)
  --verbose                           Print helpful debugging information
  -x, --expand-envs                   Replace $var in args and command with environment variables
  -h, --help                          output usage information

đź›  API Usage

EnvCmd

A function that executes a given command in a new child process with the given environment and options

  • options { object }
    • command { string }: The command to execute (node, mocha, ...)
    • commandArgs { string[] }: List of arguments to pass to the command (['-R', 'Spec'])
    • envFile { object }
      • filePath { string }: Custom path to .env file to read from (defaults to: ./.env)
      • fallback { boolean }: Should fall back to default ./.env file if custom path does not exist
    • rc { object }
      • environments { string[] }: List of environment to read from the .rc file
      • filePath { string }: Custom path to the .rc file (defaults to: ./.varzrc(|.js|.json))
    • options { object }
      • expandEnvs { boolean }: Expand $var values passed to commandArgs (default: false)
      • noOverride { boolean }: Prevent .env file vars from overriding existing process.env vars (default: false)
      • silent { boolean }: Ignore any errors thrown by varz, used to ignore missing file errors (default: false)
      • useShell { boolean }: Runs command inside a new shell instance (default: true)
      • verbose { boolean }: Prints extra debug logs to console.info (default: false)
    • Returns { Promise<object> }: key is env var name and value is the env var value

GetEnvVars

A function that parses environment variables from a .env or a .rc file

  • options { object }
    • envFile { object }
      • filePath { string }: Custom path to .env file to read from (defaults to: ./.env)
      • fallback { boolean }: Should fall back to default ./.env file if custom path does not exist
    • rc { object }
      • environments { string[] }: List of environment to read from the .rc file
      • filePath { string }: Custom path to the .rc file (defaults to: ./.varzrc(|.js|.json))
    • verbose { boolean }: Prints extra debug logs to console.info (default: false)
  • Returns { Promise<object> }: key is env var name and value is the env var value

đź§™ Why

Because sometimes it is just too cumbersome passing a lot of environment variables to scripts. It is usually just easier to have a file with all the vars in them, especially for development and testing.

🚨Do not commit sensitive environment data to a public git repo! 🚨

env-cmd - Executes a command using the environment variables in an env file cross-env - Cross platform setting of environment scripts

🎊 Special Thanks

Special thanks to env-cmd and cross-env for inspiration (uses the same cross-spawn lib underneath too).

đź“‹ Contributing Guide

I welcome all pull requests. Please make sure you add appropriate test cases for any features added. Before opening a PR please make sure to run the following scripts:

  • npm run lint checks for code errors and format according to ts-standard
  • npm test make sure all tests pass
  • npm run test-cover make sure the coverage has not decreased from current master

Keywords

env

FAQs

Package last updated on 17 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts