npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cross-env-cfg

v0.0.4

Published

Run scripts that set and use config & environment variables across platforms

Downloads

2

Readme

Run scripts that use Node.js configuration and environment variables across platforms.

This is a fork of cross-env that is modified to include a Node.js configuration file in addition to environment variables.

The problem

Most Windows command prompts will choke when you set environment variables with NODE_ENV=production as a prefix to the command invoked (The exception is [Bash on Windows][win-bash], which uses native Bash). Instead of prefixing commands with environment variables, it is more concise and powerful to specify a Node.js configuration file.

This solution

cross-env-cfg allows you to have a single command without worrying about setting or using environment variables properly for the platform. cross-env-cfg allows you to specify a Node.js configuration file (like config.js), and use a mustache-like syntax to refer to variables it defines. For example, within package.json you may execute a script referencing {{config.VAR1}} on its command line and that value may be defined within config.js as follows:

config = {
  VAR1 = process.env.VAR1 || 'DEFAULT_VAR1_VALUE';
  VAR2 = process.env.VAR2 || 'DEFAULT_VAR2_VALUE';
  VAR3 = process.env.VAR3 || 'DEFAULT_VAR3_VALUE';
}

modules.exports = config;

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies:

npm install --save-dev cross-env-cfg

WARNING! Make sure that when you're installing packages that you spell things correctly to avoid mistakenly installing malware

Usage

The following shows an example of how to use cross-env-cfg.

{
  "scripts": {
    "myCommand": "cross-env-cfg config.js echo EnvVar=$ENV_VAR1 ConfigVar={{config.VAR1}}"
  }
}

Where config.js is defined as follows:

config = {
  VAR2 = 'VALUE2'
}

modules.exports = config;

Ultimately, the command that is executed (using cross-spawn) is shown below assuming the environment variable ENV_VAR1=VALUE1 and the config.js file defines config.VAR2 = VALUE2:

echo EnvVar=VALUE1 ConfigVar=VALUE2

Other Solutions

  • env-cmd - Reads environment variables from a file instead
  • @naholyr/cross-env - cross-env with support for setting default values

LICENSE

MIT