Skip to content

Commit 637fe98

Browse files
authored
Merge pull request #7 from diujin/fixes/6
added fix for hanging loader absolute in windows #6 4d
2 parents b322f7e + fae2bb9 commit 637fe98

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/system/FileLoader.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,22 @@ export default class FileLoader {
4848
//get the absolute path
4949
pathname = path.resolve(pwd, pathname);
5050
}
51-
//if the pathname does not start with /,
52-
//the path should start with modules
53-
if (!pathname.startsWith('/') && !pathname.startsWith('\\')) {
51+
//if the pathname is not already absolute,
52+
//the path should start with modules
53+
if (!path.isAbsolute(pathname)) {
5454
let cwd = pwd;
5555
do {
5656
const module = path.resolve(cwd, 'node_modules', pathname);
5757
if (this._fs.existsSync(module)) {
5858
return module;
5959
}
60-
cwd = path.dirname(cwd);
61-
} while (cwd !== '/');
60+
const parent = path.dirname(cwd);
61+
//stops at root dir (C:\ or /)
62+
if (parent === cwd) {
63+
break;
64+
}
65+
cwd = parent;
66+
} while (true);
6267
pathname = path.resolve(this.modules(this._cwd), pathname);
6368
}
6469
if (exists && !this._fs.existsSync(pathname)) {

0 commit comments

Comments
 (0)