From 50884bf4190ec9b308a1316177df4c1e6f6012aa Mon Sep 17 00:00:00 2001 From: diujin Date: Fri, 21 Feb 2025 09:57:23 +0800 Subject: [PATCH 1/3] added fix in fileloader for yarn commands hanging in windows --- src/system/FileLoader.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/system/FileLoader.ts b/src/system/FileLoader.ts index ba6445d..e5897e2 100644 --- a/src/system/FileLoader.ts +++ b/src/system/FileLoader.ts @@ -48,17 +48,21 @@ export default class FileLoader { //get the absolute path pathname = path.resolve(pwd, pathname); } - //if the pathname does not start with /, - //the path should start with modules - if (!pathname.startsWith('/') && !pathname.startsWith('\\')) { + //check if path is not already absolute + if (!path.isAbsolute(pathname)) { let cwd = pwd; do { const module = path.resolve(cwd, 'node_modules', pathname); if (this._fs.existsSync(module)) { return module; } - cwd = path.dirname(cwd); - } while (cwd !== '/'); + const parent = path.dirname(cwd); + //stops at root dir (C:\ or /) + if (parent === cwd) { + break; + } + cwd = parent; + } while (true); pathname = path.resolve(this.modules(this._cwd), pathname); } if (exists && !this._fs.existsSync(pathname)) { From ee4952899b231e572d321eeb8daaf699cba5e275 Mon Sep 17 00:00:00 2001 From: diujin Date: Fri, 21 Feb 2025 10:19:29 +0800 Subject: [PATCH 2/3] change in comments for better reading --- src/system/FileLoader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/FileLoader.ts b/src/system/FileLoader.ts index e5897e2..fb73061 100644 --- a/src/system/FileLoader.ts +++ b/src/system/FileLoader.ts @@ -48,7 +48,7 @@ export default class FileLoader { //get the absolute path pathname = path.resolve(pwd, pathname); } - //check if path is not already absolute + //check if path is not already absolute on all os if (!path.isAbsolute(pathname)) { let cwd = pwd; do { From fae2bb9f5ff6d5d1053d73e1ddb784886897e892 Mon Sep 17 00:00:00 2001 From: diujin Date: Fri, 21 Feb 2025 13:29:35 +0800 Subject: [PATCH 3/3] changes in comments for better readability --- src/system/FileLoader.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/system/FileLoader.ts b/src/system/FileLoader.ts index fb73061..add604a 100644 --- a/src/system/FileLoader.ts +++ b/src/system/FileLoader.ts @@ -48,8 +48,9 @@ export default class FileLoader { //get the absolute path pathname = path.resolve(pwd, pathname); } - //check if path is not already absolute on all os - if (!path.isAbsolute(pathname)) { + //if the pathname is not already absolute, + //the path should start with modules + if (!path.isAbsolute(pathname)) { let cwd = pwd; do { const module = path.resolve(cwd, 'node_modules', pathname);