🎨 envShouldBePatched > shouldGetEnvFromShell

This commit is contained in:
Joe Fitzgerald 2016-08-11 17:07:21 -06:00
parent 9ec63a8ffc
commit 485cb71be7
2 changed files with 21 additions and 21 deletions

View File

@ -2,7 +2,7 @@
/* eslint-env jasmine */
import child_process from 'child_process'
import {updateProcessEnv, envShouldBePatched} from '../src/update-process-env'
import {updateProcessEnv, shouldGetEnvFromShell} from '../src/update-process-env'
import dedent from 'dedent'
describe('updateProcessEnv(launchEnv)', function () {
@ -86,30 +86,30 @@ describe('updateProcessEnv(launchEnv)', function () {
})
describe('shells on osx', function () {
it('envShouldBePatched() returns the shell when the shell should be patched', function () {
it('shouldGetEnvFromShell() returns the shell when the shell should be patched', function () {
process.platform = 'darwin'
expect(envShouldBePatched('/bin/sh')).toBe(true)
expect(envShouldBePatched('/usr/local/bin/sh')).toBe(true)
expect(envShouldBePatched('/bin/bash')).toBe(true)
expect(envShouldBePatched('/usr/local/bin/bash')).toBe(true)
expect(envShouldBePatched('/bin/zsh')).toBe(true)
expect(envShouldBePatched('/usr/local/bin/zsh')).toBe(true)
expect(envShouldBePatched('/bin/fish')).toBe(true)
expect(envShouldBePatched('/usr/local/bin/fish')).toBe(true)
expect(shouldGetEnvFromShell('/bin/sh')).toBe(true)
expect(shouldGetEnvFromShell('/usr/local/bin/sh')).toBe(true)
expect(shouldGetEnvFromShell('/bin/bash')).toBe(true)
expect(shouldGetEnvFromShell('/usr/local/bin/bash')).toBe(true)
expect(shouldGetEnvFromShell('/bin/zsh')).toBe(true)
expect(shouldGetEnvFromShell('/usr/local/bin/zsh')).toBe(true)
expect(shouldGetEnvFromShell('/bin/fish')).toBe(true)
expect(shouldGetEnvFromShell('/usr/local/bin/fish')).toBe(true)
})
it('envShouldBePatched() returns false when the shell should not be patched', function () {
it('shouldGetEnvFromShell() returns false when the shell should not be patched', function () {
process.platform = 'darwin'
expect(envShouldBePatched('/bin/unsupported')).toBe(false)
expect(envShouldBePatched('/bin/shh')).toBe(false)
expect(envShouldBePatched('/bin/tcsh')).toBe(false)
expect(envShouldBePatched('/usr/csh')).toBe(false)
expect(shouldGetEnvFromShell('/bin/unsupported')).toBe(false)
expect(shouldGetEnvFromShell('/bin/shh')).toBe(false)
expect(shouldGetEnvFromShell('/bin/tcsh')).toBe(false)
expect(shouldGetEnvFromShell('/usr/csh')).toBe(false)
})
it('envShouldBePatched() returns false when the shell is undefined or empty', function () {
it('shouldGetEnvFromShell() returns false when the shell is undefined or empty', function () {
process.platform = 'darwin'
expect(envShouldBePatched(undefined)).toBe(false)
expect(envShouldBePatched('')).toBe(false)
expect(shouldGetEnvFromShell(undefined)).toBe(false)
expect(shouldGetEnvFromShell('')).toBe(false)
})
})
})

View File

@ -40,7 +40,7 @@ function updateProcessEnv (launchEnv) {
}
}
function envShouldBePatched (shell) {
function shouldGetEnvFromShell (shell) {
if (!shell || shell.trim() === '') {
return false
}
@ -55,7 +55,7 @@ function envShouldBePatched (shell) {
function getEnvFromShell () {
let shell = process.env.SHELL
if (!envShouldBePatched(shell)) {
if (!shouldGetEnvFromShell(shell)) {
return
}
@ -74,4 +74,4 @@ function getEnvFromShell () {
}
}
export default { updateProcessEnv, envShouldBePatched }
export default { updateProcessEnv, shouldGetEnvFromShell }