From 22f70c86f574770f49532a25c789fea23dc90a86 Mon Sep 17 00:00:00 2001 From: Godzil Date: Wed, 1 Aug 2018 00:48:38 +0100 Subject: [PATCH] Add a function to make the cookie monster happy! --- src/my_request.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/my_request.ts b/src/my_request.ts index 721a87e..8303f07 100644 --- a/src/my_request.ts +++ b/src/my_request.ts @@ -78,7 +78,6 @@ function login(sessionId: string, user: string, pass: string): Promise }); } -// TODO: logout function loadCookies(config: IConfig) { const cookiePath = path.join(config.output || process.cwd(), '.cookies.json'); @@ -89,6 +88,17 @@ function loadCookies(config: IConfig) j = request.jar(new cookieStore(cookiePath)); } +export function eatCookies(config: IConfig) +{ + const cookiePath = path.join(config.output || process.cwd(), '.cookies.json'); + + if(fs.existsSync(cookiePath)) + { + fs.removeSync(cookiePath); + } + j = undefined; +} + /** * Performs a GET request for the resource. */