From 2acc5af4cde5245f5336e9b50ff7acd1c60dd864 Mon Sep 17 00:00:00 2001 From: Fazendaaa Date: Sat, 20 Oct 2018 23:39:37 -0300 Subject: [PATCH 01/10] Adding TS typings. --- index.d.ts | 17 +++++++++++++++++ package.json | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..52f26e5 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,17 @@ +declare module 'shell-env' { + /** + * Get the environment variables defined in your dotfiles + * + * @param shell To read the environment variables from + * @returns The environment variables + */ + function sync(shell?: string): object; + + /** + * Get the environment variables defined in your dotfiles + * + * @param shell To read the environment variables from + * @returns The environment variables + */ + export default function shellEnv(shell?: string): Promise; +} diff --git a/package.json b/package.json index 2448148..d49446e 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "2.1.0", "description": "Get environment variables from the shell", "license": "MIT", + "types": "index.d.ts", "repository": "sindresorhus/shell-env", "author": { "name": "Sindre Sorhus", @@ -16,7 +17,8 @@ "test": "xo && ava" }, "files": [ - "index.js" + "index.js", + "index.d.ts" ], "keywords": [ "env", From 38730b440ff8974ce8b3957f915a50ab7993558f Mon Sep 17 00:00:00 2001 From: Fazendaaa Date: Tue, 23 Oct 2018 22:44:13 -0300 Subject: [PATCH 02/10] Updating after feedback. --- index.d.ts | 38 ++++++++++++++++++++++---------------- index.test-d.ts | 7 +++++++ package.json | 9 +++++++-- 3 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 index.test-d.ts diff --git a/index.d.ts b/index.d.ts index 52f26e5..0205ed0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,17 +1,23 @@ -declare module 'shell-env' { - /** - * Get the environment variables defined in your dotfiles - * - * @param shell To read the environment variables from - * @returns The environment variables - */ - function sync(shell?: string): object; - - /** - * Get the environment variables defined in your dotfiles - * - * @param shell To read the environment variables from - * @returns The environment variables - */ - export default function shellEnv(shell?: string): Promise; +export interface ShellEnv { + readonly [x: string]: string; + readonly SHELL: string; + readonly TERM_PROGRAM: string; } + +/** + * Get the environment variables defined in your dotfiles. + * + * @param shell To read the environment variables from. + * @returns The environment variables. + */ +export function sync(shell?: string): ShellEnv; + +/** + * Get the environment variables defined in your dotfiles. + * + * @param shell To read the environment variables from. + * @returns The environment variables. + */ +export function shellEnv(shell?: string): Promise; + +export default shellEnv; diff --git a/index.test-d.ts b/index.test-d.ts new file mode 100644 index 0000000..a9a73d8 --- /dev/null +++ b/index.test-d.ts @@ -0,0 +1,7 @@ +import {expectType} from 'tsd-check'; +import shellEnv, { sync, ShellEnv } from '.'; + +(async () => { + expectType(sync()); + expectType(await shellEnv()); +})(); diff --git a/package.json b/package.json index d49446e..05dd37f 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,6 @@ "version": "2.1.0", "description": "Get environment variables from the shell", "license": "MIT", - "types": "index.d.ts", "repository": "sindresorhus/shell-env", "author": { "name": "Sindre Sorhus", @@ -14,7 +13,7 @@ "node": ">=6" }, "scripts": { - "test": "xo && ava" + "test": "xo && ava && tsd-check" }, "files": [ "index.js", @@ -41,6 +40,12 @@ }, "devDependencies": { "ava": "*", + "tsd-check": "^0.2.1", "xo": "*" + }, + "xo": { + "ignores": [ + "*.ts" + ] } } From de93643415cb27136fdd5ef63eaf95665c3bc0b8 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 24 Oct 2018 07:48:07 -0300 Subject: [PATCH 03/10] Update index.d.ts Co-Authored-By: Fazendaaa --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 0205ed0..a89fa05 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,4 @@ -export interface ShellEnv { +export interface EnvironmentVariables { readonly [x: string]: string; readonly SHELL: string; readonly TERM_PROGRAM: string; From 9e13eab4640faf46668fb6307485743a9986c0a8 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 24 Oct 2018 07:48:15 -0300 Subject: [PATCH 04/10] Update index.d.ts Co-Authored-By: Fazendaaa --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index a89fa05..e2c9d60 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,5 +1,5 @@ export interface EnvironmentVariables { - readonly [x: string]: string; + readonly [key: string]: string; readonly SHELL: string; readonly TERM_PROGRAM: string; } From a8a00a5c18474c1b0fa59d1e44125d007e29a252 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 24 Oct 2018 07:49:14 -0300 Subject: [PATCH 05/10] Update index.test-d.ts Co-Authored-By: Fazendaaa --- index.test-d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.test-d.ts b/index.test-d.ts index a9a73d8..ae915b5 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,5 +1,5 @@ import {expectType} from 'tsd-check'; -import shellEnv, { sync, ShellEnv } from '.'; +import shellEnv, {sync, ShellEnv} from '.'; (async () => { expectType(sync()); From 4fb98120baec00d5d6a24ff92f803e39169415ce Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 24 Oct 2018 07:50:45 -0300 Subject: [PATCH 06/10] Update index.d.ts Co-Authored-By: Fazendaaa --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index e2c9d60..fa86235 100644 --- a/index.d.ts +++ b/index.d.ts @@ -15,7 +15,7 @@ export function sync(shell?: string): ShellEnv; /** * Get the environment variables defined in your dotfiles. * - * @param shell To read the environment variables from. + * @param shell - The shell to read the environment variables from. * @returns The environment variables. */ export function shellEnv(shell?: string): Promise; From a57a0a71f516a63ff64778cf34694c845c3ee1bf Mon Sep 17 00:00:00 2001 From: Fazendaaa Date: Wed, 24 Oct 2018 07:58:03 -0300 Subject: [PATCH 07/10] After owner code review. --- index.d.ts | 14 ++++++-------- index.test-d.ts | 8 +++----- package.json | 5 ----- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/index.d.ts b/index.d.ts index fa86235..ec6a3ca 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,23 +1,21 @@ export interface EnvironmentVariables { readonly [key: string]: string; - readonly SHELL: string; - readonly TERM_PROGRAM: string; } /** * Get the environment variables defined in your dotfiles. * - * @param shell To read the environment variables from. + * @param shell=User default shell - The shell to read the environment variables + * from. When * @returns The environment variables. */ -export function sync(shell?: string): ShellEnv; +export function sync(shell?: string): EnvironmentVariables; /** * Get the environment variables defined in your dotfiles. * - * @param shell - The shell to read the environment variables from. + * @param shell=User default shell - The shell to read the environment variables + * from. When * @returns The environment variables. */ -export function shellEnv(shell?: string): Promise; - -export default shellEnv; +export default function shellEnv(shell?: string): Promise; diff --git a/index.test-d.ts b/index.test-d.ts index ae915b5..a5ef803 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,7 +1,5 @@ import {expectType} from 'tsd-check'; -import shellEnv, {sync, ShellEnv} from '.'; +import shellEnv, {sync, EnvironmentVariables} from '.'; -(async () => { - expectType(sync()); - expectType(await shellEnv()); -})(); +expectType(sync()); +expectType(await shellEnv()); diff --git a/package.json b/package.json index 05dd37f..0e710b5 100644 --- a/package.json +++ b/package.json @@ -42,10 +42,5 @@ "ava": "*", "tsd-check": "^0.2.1", "xo": "*" - }, - "xo": { - "ignores": [ - "*.ts" - ] } } From 7cd575164baab06547c92bf3c5c6fa47fb53deb0 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 1 Feb 2019 12:10:23 +0700 Subject: [PATCH 08/10] Update index.d.ts --- index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index ec6a3ca..264c6b2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -5,8 +5,8 @@ export interface EnvironmentVariables { /** * Get the environment variables defined in your dotfiles. * - * @param shell=User default shell - The shell to read the environment variables - * from. When + * @param shell - The shell to read the environment variables + * from. Default: User default shell. * @returns The environment variables. */ export function sync(shell?: string): EnvironmentVariables; @@ -14,8 +14,8 @@ export function sync(shell?: string): EnvironmentVariables; /** * Get the environment variables defined in your dotfiles. * - * @param shell=User default shell - The shell to read the environment variables - * from. When + * @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; From 167427b5009c8fd3e26fa4bbb2ffd96ee1f56caa Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 1 Feb 2019 12:10:43 +0700 Subject: [PATCH 09/10] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e710b5..a529455 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ }, "devDependencies": { "ava": "*", - "tsd-check": "^0.2.1", + "tsd-check": "^0.3.0", "xo": "*" } } From 97586763c38f5db4b07ca78b66baba310664414e Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 1 Feb 2019 12:11:10 +0700 Subject: [PATCH 10/10] Update index.d.ts --- index.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 264c6b2..c7dc831 100644 --- a/index.d.ts +++ b/index.d.ts @@ -5,8 +5,7 @@ export interface 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 the environment variables from. Default: User default shell. * @returns The environment variables. */ export function sync(shell?: string): EnvironmentVariables; @@ -14,8 +13,7 @@ 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 the environment variables from. Default: User default shell. * @returns The environment variables. */ export default function shellEnv(shell?: string): Promise;