From 3305f1dc8f385ab180881251d68e4b1ae47aa09a Mon Sep 17 00:00:00 2001 From: Medhansh404 <21ucs126@lnmiit.ac.in> Date: Thu, 28 Dec 2023 21:43:45 +0530 Subject: [PATCH 1/6] described error logging in setting home directory --- sources/folderUtils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sources/folderUtils.ts b/sources/folderUtils.ts index 1d2d70b83..9bf6ef50a 100644 --- a/sources/folderUtils.ts +++ b/sources/folderUtils.ts @@ -39,7 +39,7 @@ export function getInstallFolder() { } export function getTemporaryFolder(target: string = tmpdir()) { - mkdirSync(target, {recursive: true}); + mkdirSync(target, { recursive: true }); while (true) { const rnd = Math.random() * 0x100000000; @@ -52,9 +52,11 @@ export function getTemporaryFolder(target: string = tmpdir()) { } catch (error) { if ((error as NodeError).code === `EEXIST`) { continue; + } else if ((error as NodeError).code === `EACCES`) { + throw new Error(`Failed to create cache directory. Please ensure the user has write access to the target directory (${target}). If the user's home directory does not exist, create it first.`); } else { throw error; } } } -} +} \ No newline at end of file From f8184da5fe26262482d9bc522b56c1cc777b2738 Mon Sep 17 00:00:00 2001 From: Medhansh404 <21ucs126@lnmiit.ac.in> Date: Fri, 29 Dec 2023 19:56:39 +0530 Subject: [PATCH 2/6] error logging --- .vscode/settings.json | 2 +- sources/folderUtils.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e840f5983..090a46fd4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,6 @@ "eslint.nodePath": ".yarn/sdks", "typescript.enablePromptUseWorkspaceTsdk": true, "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" } } diff --git a/sources/folderUtils.ts b/sources/folderUtils.ts index 9bf6ef50a..f7d588042 100644 --- a/sources/folderUtils.ts +++ b/sources/folderUtils.ts @@ -4,6 +4,7 @@ import {join} from 'path'; import process from 'process'; import type {NodeError} from './nodeUtils'; +import {UsageError} from 'clipanion'; export function getInstallFolder() { if (process.env.COREPACK_HOME == null) { @@ -53,7 +54,7 @@ export function getTemporaryFolder(target: string = tmpdir()) { if ((error as NodeError).code === `EEXIST`) { continue; } else if ((error as NodeError).code === `EACCES`) { - throw new Error(`Failed to create cache directory. Please ensure the user has write access to the target directory (${target}). If the user's home directory does not exist, create it first.`); + throw new UsageError(`Failed to create cache directory. Please ensure the user has write access to the target directory (${target}). If the user's home directory does not exist, create it first.`, {cause: error}); } else { throw error; } From bbad72bc3ea31c2794098a0b886cc80fe24f0ea9 Mon Sep 17 00:00:00 2001 From: Medhansh404 <21ucs126@lnmiit.ac.in> Date: Fri, 29 Dec 2023 19:59:01 +0530 Subject: [PATCH 3/6] error logging --- .vscode/settings.json | 2 +- sources/folderUtils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 090a46fd4..e840f5983 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,6 @@ "eslint.nodePath": ".yarn/sdks", "typescript.enablePromptUseWorkspaceTsdk": true, "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit" + "source.fixAll.eslint": true } } diff --git a/sources/folderUtils.ts b/sources/folderUtils.ts index f7d588042..29b5473f5 100644 --- a/sources/folderUtils.ts +++ b/sources/folderUtils.ts @@ -40,7 +40,7 @@ export function getInstallFolder() { } export function getTemporaryFolder(target: string = tmpdir()) { - mkdirSync(target, { recursive: true }); + mkdirSync(target, {recursive: true}); while (true) { const rnd = Math.random() * 0x100000000; From 690145dec032d7ba9ac3843c87e360257fd467d1 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 29 Dec 2023 16:39:43 +0100 Subject: [PATCH 4/6] Update sources/folderUtils.ts --- sources/folderUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/folderUtils.ts b/sources/folderUtils.ts index 29b5473f5..8c3e3b634 100644 --- a/sources/folderUtils.ts +++ b/sources/folderUtils.ts @@ -60,4 +60,4 @@ export function getTemporaryFolder(target: string = tmpdir()) { } } } -} \ No newline at end of file +} From 02f00e2fc3241ca36f8578c9e0952e5d7663a050 Mon Sep 17 00:00:00 2001 From: Medhansh404 <21ucs126@lnmiit.ac.in> Date: Fri, 29 Dec 2023 21:27:08 +0530 Subject: [PATCH 5/6] error logging --- sources/folderUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/folderUtils.ts b/sources/folderUtils.ts index 8c3e3b634..721327b41 100644 --- a/sources/folderUtils.ts +++ b/sources/folderUtils.ts @@ -54,7 +54,7 @@ export function getTemporaryFolder(target: string = tmpdir()) { if ((error as NodeError).code === `EEXIST`) { continue; } else if ((error as NodeError).code === `EACCES`) { - throw new UsageError(`Failed to create cache directory. Please ensure the user has write access to the target directory (${target}). If the user's home directory does not exist, create it first.`, {cause: error}); + throw new UsageError(`Failed to create cache directory. Please ensure the user has write access to the target directory (${target}). If the user's home directory does not exist, create it first.`); } else { throw error; } From 6c45e8dbc1207162060e27f9a0672bcbdca4f086 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 29 Dec 2023 23:28:43 +0100 Subject: [PATCH 6/6] Update folderUtils.ts --- sources/folderUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/folderUtils.ts b/sources/folderUtils.ts index 721327b41..340e4d3df 100644 --- a/sources/folderUtils.ts +++ b/sources/folderUtils.ts @@ -1,10 +1,10 @@ +import {UsageError} from 'clipanion'; import {existsSync, mkdirSync, renameSync} from 'fs'; import {homedir, tmpdir} from 'os'; import {join} from 'path'; import process from 'process'; import type {NodeError} from './nodeUtils'; -import {UsageError} from 'clipanion'; export function getInstallFolder() { if (process.env.COREPACK_HOME == null) {