|
1 | | -declare namespace shellEnv { |
2 | | - interface EnvironmentVariables { |
3 | | - readonly [key: string]: string; |
4 | | - } |
5 | | -} |
6 | | - |
7 | | -declare const shellEnv: { |
8 | | - /** |
9 | | - Get the environment variables defined in your dotfiles. |
10 | | -
|
11 | | - @param shell - The shell to read environment variables from. Default: User default shell. |
12 | | - @returns The environment variables. |
13 | | -
|
14 | | - @example |
15 | | - ``` |
16 | | - import shellEnv = require('shell-env'); |
17 | | -
|
18 | | - console.log(shellEnv.sync()); |
19 | | - //=> {TERM_PROGRAM: 'Apple_Terminal', SHELL: '/bin/zsh', ...} |
20 | | -
|
21 | | - console.log(shellEnv.sync('/bin/bash')); |
22 | | - //=> {TERM_PROGRAM: 'iTerm.app', SHELL: '/bin/zsh', ...} |
23 | | - ``` |
24 | | - */ |
25 | | - (shell?: string): Promise<shellEnv.EnvironmentVariables>; |
26 | | - |
27 | | - /** |
28 | | - Get the environment variables defined in your dotfiles. |
29 | | -
|
30 | | - @param shell - The shell to read environment variables from. Default: User default shell. |
31 | | - @returns The environment variables. |
32 | | - */ |
33 | | - sync(shell?: string): shellEnv.EnvironmentVariables; |
34 | | -}; |
35 | | - |
36 | | -export = shellEnv; |
| 1 | +export type EnvironmentVariables = Readonly<Record<string, string>>; |
| 2 | + |
| 3 | +/** |
| 4 | +Get the environment variables defined in your dotfiles. |
| 5 | +
|
| 6 | +@param shell - The shell to read environment variables from. Default: User default shell. |
| 7 | +@returns The environment variables. |
| 8 | +
|
| 9 | +@example |
| 10 | +``` |
| 11 | +import {shellEnv} from 'shell-env'; |
| 12 | +
|
| 13 | +console.log(await shellEnv()); |
| 14 | +//=> {TERM_PROGRAM: 'Apple_Terminal', SHELL: '/bin/zsh', ...} |
| 15 | +
|
| 16 | +console.log(await shellEnv('/bin/bash')); |
| 17 | +//=> {TERM_PROGRAM: 'iTerm.app', SHELL: '/bin/zsh', ...} |
| 18 | +``` |
| 19 | +*/ |
| 20 | +export function shellEnv(shell?: string): Promise<EnvironmentVariables>; |
| 21 | + |
| 22 | +/** |
| 23 | +Get the environment variables defined in your dotfiles. |
| 24 | +
|
| 25 | +@param shell - The shell to read environment variables from. Default: User default shell. |
| 26 | +@returns The environment variables. |
| 27 | +
|
| 28 | +@example |
| 29 | +``` |
| 30 | +import {shellEnvSync} from 'shell-env'; |
| 31 | +
|
| 32 | +console.log(shellEnvSync()); |
| 33 | +//=> {TERM_PROGRAM: 'Apple_Terminal', SHELL: '/bin/zsh', ...} |
| 34 | +
|
| 35 | +console.log(shellEnvSync('/bin/bash')); |
| 36 | +//=> {TERM_PROGRAM: 'iTerm.app', SHELL: '/bin/zsh', ...} |
| 37 | +``` |
| 38 | +*/ |
| 39 | +export function shellEnvSync(shell?: string): EnvironmentVariables; |
0 commit comments