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

env-pass

v1.0.1

Published

A CLI utility that lets you pass env-vars to CLI tools on windows, Mac and linux alike.

Downloads

10

Readme

env-pass Build Status

A CLI utility that lets you pass env-params to CLI tools on windows, Mac and linux alike.

Overview

While passing env-parameters is done differently on *n*x and on windows, one may encounter a problem with tools that relay on environment-variables as an input for feature-flags or env-switches.

The linux/Mac/Unix form:

$ PARAM1=value PARAM2=value the-program args1 args2 args3

The windows form:

> Set PARAM1=value
> Set PARAM2=value
> the-program args1 args2 args3

As long as these tools are ran mannually, it stays a matter of style.

But when the tools are run as a part of a unified automated flow that should run the same accross platforms - e.g. commands expressed in scripts section of package.json as part of your test flow - the problem becomes a nuisance this tool comes to solve.

Install

npm install env-pass --global

(or localy, AND make sure your PATH includes ./node_modules/.bin)

Usage

Synopsis

env-pass [[<param>=<value>] ... ] <script> <arg> <arg> -<switch> -<switch> <switch-value>

Example

env-pass PORT=3001 bin/my-svc arg1 --switch1 --switch2 --switch3 sw-value arg2 arg3

How does it work?

The tool exposes the CLI command env-pass. When ran, it takes advantage of the fact that program tools almost certainly will never use the equal-sign (=) as a part of their file name. (although file-systems allow equal sign as part of file names)

Implied from that:

  1. every leading expression that inlcudes the equal-sign (=) is basically a setting of an env parameter passed to the script.
  2. The first element wihtout = is the script command
  3. anything after the script name is args and switches passed to the program

Then the tool checks if the task command is a local script file.

In either case, the child process gets the injected environment variables, cascading any existing environment variables with same name.

Once spawned/forked, it makes sure to pass any SIGINT, SIGTERM to the child process, and if it's a local script - it also propagates IPC messages.

Caveates

SIGTERM and SIGINT do not pass well on windows because of how node handles these signals on windows (soemthing to do with libuv).

We encountered problems on windows when trying to work with istanbul, where istanbul was running the SUT(System-Under-Test) which was a web-server, and in the end of the test istanbul should terminate gracefully, and generate the coverage reports. By the book, we're asked to run istanbul with the --handle-sigint switch.

But.

In effect, the child process is effectively killed, and coverage reports were not generated. The problem worsens with nodist on windows, that adds a go shim layer.

If you need your target script to accept SIGINT/SIGTERM messages (e.g. signal to the SUT to shut-down gracefully) you should consider supporting an additional alternative way to ask termination of that process.

The easiest shim is have your context file respond to a specific IPC message with termination code (I'll leave the code-word to you), in addition to hooking process.on('SIGINT' and 'SIGTERM'.

If you chose to do so - you'll have to run the script as a local script (not a CLI installed with --global) and run the actual node-file.

e.g. instead of istanbul run node_modules/istanbul/lib/cli

Future

  • need to connect to travis
  • need to connect to a builder with windows platform

Contribute

  • Using PRs
  • make sure all tests pass

Lisence

MIT, and that's it :)