Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript definition #13

Merged
merged 10 commits into from Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions index.d.ts
@@ -0,0 +1,19 @@
export interface EnvironmentVariables {
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.
* @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.
* @returns The environment variables.
*/
export default function shellEnv(shell?: string): Promise<EnvironmentVariables>;
5 changes: 5 additions & 0 deletions index.test-d.ts
@@ -0,0 +1,5 @@
import {expectType} from 'tsd-check';
import shellEnv, {sync, EnvironmentVariables} from '.';

expectType<EnvironmentVariables>(sync());
expectType<EnvironmentVariables>(await shellEnv());
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -13,10 +13,11 @@
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd-check"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"keywords": [
"env",
Expand All @@ -39,6 +40,7 @@
},
"devDependencies": {
"ava": "*",
"tsd-check": "^0.3.0",
"xo": "*"
}
}