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

cross-env

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cross-env - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

4

dist/index.js

@@ -19,3 +19,3 @@ 'use strict';

var envSetterRegex = /(\w+)=(\w+)/;
var envSetterRegex = /(\w+)=('(.+)'|"(.+)"|(.+))/;

@@ -44,3 +44,3 @@ function crossEnv(args) {

if (match) {
envVars[match[1]] = match[2];
envVars[match[1]] = match[3] || match[4] || match[5];
} else {

@@ -47,0 +47,0 @@ command = shifted;

{
"name": "cross-env",
"version": "1.0.5",
"version": "1.0.6",
"description": "Run commands that set environment variables across platforms",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -5,3 +5,3 @@ import {spawn} from 'cross-spawn-async';

const envSetterRegex = /(\w+)=(\w+)/;
const envSetterRegex = /(\w+)=('(.+)'|"(.+)"|(.+))/;

@@ -23,3 +23,3 @@ function crossEnv(args) {

if (match) {
envVars[match[1]] = match[2];
envVars[match[1]] = match[3] || match[4] || match[5];
} else {

@@ -26,0 +26,0 @@ command = shifted;

@@ -25,9 +25,38 @@ import chai from 'chai';

it(`should set environment variables and run the remaining command`, () => {
testEnvSetting('FOO_ENV=production');
testEnvSetting({
FOO_ENV: 'production'
}, 'FOO_ENV=production');
});
it(`should handle multiple env variables`, () => {
testEnvSetting('FOO_ENV=production', 'bar_env=dev');
testEnvSetting({
FOO_ENV: 'production',
BAR_ENV: 'dev'
}, 'FOO_ENV=production', 'BAR_ENV=dev');
});
it(`should handle special characters`, () => {
testEnvSetting({
FOO_ENV: './!?'
}, 'FOO_ENV=./!?');
});
it(`should handle single-quoted strings`, () => {
testEnvSetting({
FOO_ENV: 'bar env'
}, 'FOO_ENV=\'bar env\'');
});
it(`should handle double-quoted strings`, () => {
testEnvSetting({
FOO_ENV: 'bar env'
}, 'FOO_ENV="bar env"');
});
it(`should handle equality signs in quoted strings`, () => {
testEnvSetting({
FOO_ENV: 'foo=bar'
}, 'FOO_ENV="foo=bar"');
});
it(`should do nothing given no command`, () => {

@@ -38,10 +67,7 @@ crossEnv([]);

function testEnvSetting(...envSettings) {
function testEnvSetting(expected, ...envSettings) {
const ret = crossEnv([...envSettings, 'echo', 'hello world']);
const env = {[getPathVar()]: process.env[getPathVar()]};
env.APPDATA = process.env.APPDATA;
envSettings.forEach(setting => {
const [prop, val] = setting.split('=');
env[prop] = val;
});
assign(env, expected);

@@ -51,5 +77,8 @@ expect(ret, 'returns what spawn returns').to.equal('spawn-returned');

expect(proxied['cross-spawn-async'].spawn).to.have.been.calledWith(
'echo', ['hello world'], {stdio: 'inherit', env: assign({}, process.env, env)}
'echo', ['hello world'], {
stdio: 'inherit',
env: assign({}, process.env, env)
}
);
}
});
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