Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
b60d531
commit 235d4eb
Showing
7 changed files
with
79 additions
and
78 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
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,39 @@ | ||
declare namespace shellEnv { | ||
interface EnvironmentVariables { | ||
readonly [key: string]: string; | ||
} | ||
} | ||
|
||
declare const shellEnv: { | ||
/** | ||
Get the environment variables defined in your dotfiles. | ||
@param shell - The shell to read environment variables from. Default: User default shell. | ||
@returns The environment variables. | ||
@example | ||
``` | ||
import shellEnv = require('shell-env'); | ||
console.log(shellEnv.sync()); | ||
//=> {TERM_PROGRAM: 'Apple_Terminal', SHELL: '/bin/zsh', ...} | ||
console.log(shellEnv.sync('/bin/bash')); | ||
//=> {TERM_PROGRAM: 'iTerm.app', SHELL: '/bin/zsh', ...} | ||
``` | ||
*/ | ||
(shell?: string): Promise<shellEnv.EnvironmentVariables>; | ||
|
||
/** | ||
Get the environment variables defined in your dotfiles. | ||
@param shell - The shell to read environment variables from. Default: User default shell. | ||
@returns The environment variables. | ||
*/ | ||
sync(shell?: string): shellEnv.EnvironmentVariables; | ||
}; | ||
|
||
export = shellEnv; | ||
export type EnvironmentVariables = Readonly<Record<string, string>>; | ||
|
||
/** | ||
Get the environment variables defined in your dotfiles. | ||
@param shell - The shell to read environment variables from. Default: User default shell. | ||
@returns The environment variables. | ||
@example | ||
``` | ||
import {shellEnv} from 'shell-env'; | ||
console.log(await shellEnv()); | ||
//=> {TERM_PROGRAM: 'Apple_Terminal', SHELL: '/bin/zsh', ...} | ||
console.log(await shellEnv('/bin/bash')); | ||
//=> {TERM_PROGRAM: 'iTerm.app', SHELL: '/bin/zsh', ...} | ||
``` | ||
*/ | ||
export function shellEnv(shell?: string): Promise<EnvironmentVariables>; | ||
|
||
/** | ||
Get the environment variables defined in your dotfiles. | ||
@param shell - The shell to read environment variables from. Default: User default shell. | ||
@returns The environment variables. | ||
@example | ||
``` | ||
import {shellEnvSync} from 'shell-env'; | ||
console.log(shellEnvSync()); | ||
//=> {TERM_PROGRAM: 'Apple_Terminal', SHELL: '/bin/zsh', ...} | ||
console.log(shellEnvSync('/bin/bash')); | ||
//=> {TERM_PROGRAM: 'iTerm.app', SHELL: '/bin/zsh', ...} | ||
``` | ||
*/ | ||
export function shellEnvSync(shell?: string): 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import {expectType} from 'tsd'; | ||
import shellEnv = require('.'); | ||
import {EnvironmentVariables} from '.'; | ||
import {shellEnv, shellEnvSync, EnvironmentVariables} from './index.js'; | ||
|
||
expectType<EnvironmentVariables>(shellEnv.sync()); | ||
expectType<Promise<EnvironmentVariables>>(shellEnv()); | ||
expectType<EnvironmentVariables>(shellEnvSync()); |
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