Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-env

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-env

Add env vars from a .env file to your process.env

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.3K
decreased by-0.54%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-env

Add env vars from a .env file to your process.env

Install

npm i --save-dev gulp-env

Usage

For now, gulp-env expects the .env file to export a javascript object, i.e.:

//.env
module.exports = {
	MONGO_URI: "mongodb://localhost:27017/testdb
}

You can add the properties of this object to your process.env via env({file: ".env}) in your gulpfile.

//gulpfile.js
gulp = require('gulp'),
  nodemon = require('nodemon'),
  env = require('gulp-env');

gulp.task('nodemon', function() {
	//nodemon server ...
});

gulp.task('set-env', function () {
	env({file: ".env"});
});

gulp.task('default', ['set-env', 'nodemon'])

TODO

For now, this plug-in is stupid simple.

Seriously, this is all of the code!

'use strict';

module.exports = function(options) {
  if (options.file) {
    var env = require("./" + options.file);

    for (var prop in env) {
      process.env[prop] = env[prop]
    }
  }
}

TODO:

  • handle non-module.exports env files
  • allow for simple variable setting (i.e. env({PORT: 4000}), etc.)
  • test coverage

Keywords

FAQs

Package last updated on 12 Sep 2014

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc