Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bec9ece
commit 44f7233
Showing
4 changed files
with
20 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
export interface EnvironmentVariables { | ||
readonly [key: string]: string; | ||
readonly [key: string]: string; | ||
} | ||
|
||
/** | ||
* Get the environment variables defined in your dotfiles. | ||
* | ||
* @param shell - The shell to read the environment variables from. Default: User default shell. | ||
* @param shell - The shell to read environment variables from. Default: User default shell. | ||
* @returns The environment variables. | ||
*/ | ||
export function sync(shell?: string): EnvironmentVariables; | ||
|
||
/** | ||
* Get the environment variables defined in your dotfiles. | ||
* | ||
* @param shell - The shell to read the environment variables from. Default: User default shell. | ||
* | ||
* @param shell - The shell to read environment variables from. Default: User default shell. | ||
* @returns The environment variables. | ||
*/ | ||
export default function shellEnv(shell?: string): Promise<EnvironmentVariables>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,38 @@ | ||
import test from 'ava'; | ||
import m from '.'; | ||
import shellEnv from '.'; | ||
|
||
test('async', async t => { | ||
const env = await m(); | ||
const env = await shellEnv(); | ||
t.true('HOME' in env); | ||
t.false('' in env); | ||
}); | ||
|
||
test('sync', t => { | ||
const env = m.sync(); | ||
const env = shellEnv.sync(); | ||
t.true('HOME' in env); | ||
t.false('' in env); | ||
}); | ||
|
||
test('async with custom shell', async t => { | ||
const shell = '/bin/bash'; | ||
const env = await m(shell); | ||
const env = await shellEnv(shell); | ||
t.true('HOME' in env); | ||
t.false('' in env); | ||
}); | ||
|
||
test('sync with custom shell', t => { | ||
const shell = '/bin/bash'; | ||
const env = m.sync(shell); | ||
const env = shellEnv.sync(shell); | ||
t.true('HOME' in env); | ||
t.false('' in env); | ||
}); | ||
|
||
test('sync with custom shell throws on non-executable', t => { | ||
t.throws(() => m.sync('non-executable')); | ||
t.throws(() => { | ||
shellEnv.sync('non-executable'); | ||
}); | ||
}); | ||
|
||
test('async with custom shell throws on non-executable', async t => { | ||
await t.throws(m('non-executable')); | ||
await t.throwsAsync(shellEnv('non-executable')); | ||
}); |