Skip to content
This repository was archived by the owner on Jul 31, 2024. It is now read-only.
/ envscript Public archive

Define environment variables on a per script basis in your package.json.

Notifications You must be signed in to change notification settings

alecmekarzel/envscript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

███████████████████████████████████████████████████████████
 █████  ██████   ██████ ██   ██ ██ ██    ██ ███████ ██████  
██   ██ ██   ██ ██      ██   ██ ██ ██    ██ ██      ██   ██ 
███████ ██████  ██      ███████ ██ ██    ██ █████   ██   ██ 
██   ██ ██   ██ ██      ██   ██ ██  ██  ██  ██      ██   ██ 
██   ██ ██   ██  ██████ ██   ██ ██   ████   ███████ ██████  

This project was built over seven years ago as a quick-use utility and fun project not meant for production purposes. It has since been archived.

However, feel free to peruse, fork, modify, and so forth!

███████████████████████████████████████████████████████████

envscript

Define environment variables on a per script basis in your package.json.

Installation

# NPM
$ npm install envscript

# Yarn
$ yarn add envscript

Getting Started

All you have to do is define your scripts and your envscripts inside your package.json. Every command in scripts should reference a field in envscripts.

Don't be confused by this explanation, it's really simple. Take a look at the example below.

Via Package.json

{
	"scripts": {
		"start": "envscript start",
		"test": "envscript test"
	},
	"envscripts": {
		"start": {
			"run": "node index.js",
			"env": {
				"NODE_ENV": "production",
				"HOST": "localhost",
				"PORT": 3000
			}
		},
		"test": "mocha"
	},
}

As you can see, we have a few simple scripts which run envscript <command>. When envscript <command> executes, it will look in the envscripts field in your package.json for that <command> and attempt to run it. And then that's where the magic happens.

You might also notice that there's two ways of defining an envscript.

There's the magical way you're not used to seeing:

"start": {
	"run": "node index.js",
	"env": {
		"NODE_ENV": "production",
		"HOST": "localhost",
		"PORT": 3000
	}
}

And then there's the traditional way that you'd use for any normal script:

"test": "mocha"

We think these are both pretty intuitive and readable.

Testing

Simply run npm test or yarn test (depending on your package manager) and the tests for this package will be run.

Issues

We don't accept issues; we accept pull requests.

Changelog

For milestones, visit the project's releases.

License

For license information, visit the project's license.

About

Define environment variables on a per script basis in your package.json.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published