From ac351eb4c008ec0b9ce475c733ca2308ae6b3957 Mon Sep 17 00:00:00 2001 From: Ramon Brullo Date: Sat, 13 Jan 2024 12:39:54 +0100 Subject: [PATCH] refactor: type npm-login result Add type for the return of `npmLogin`. --- src/cmd-login.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmd-login.ts b/src/cmd-login.ts index debe3017..701361c9 100644 --- a/src/cmd-login.ts +++ b/src/cmd-login.ts @@ -83,6 +83,11 @@ export const login = async function ( return 0; }; +/** + * The result of a login attempt. Either success with the token, or failure. + */ +type LoginResult = { code: 0; token: string } | { code: 1 }; + /** * Return npm login token */ @@ -91,7 +96,7 @@ const npmLogin = async function ( password: string, email: string, registry: RegistryUrl -) { +): Promise { const client = getNpmClient(); try { const data = await client.adduser(registry, {