Skip to content

Commit 32cc513

Browse files
committed
fix: improve local configRegister file resolution
Fixes #746 by first checking, if the dependency is a local file or a package. module.paths doesn't work for requiring local paths.
1 parent 44df902 commit 32cc513

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/groups/config.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,17 @@ class ConfigGroup extends GroupHelper {
4646

4747
this.configOptions = (() => {
4848
if (register && register.length) {
49-
module.paths.unshift(resolve(process.cwd(), 'node_modules'), process.cwd());
49+
module.paths.unshift(resolve(process.cwd(), 'node_modules'));
5050
register.forEach(dep => {
51-
require(dep);
51+
const isRelative = ["./", "../", ".\\", "..\\"].some(start => dep.startsWith(start));
52+
if (isRelative) {
53+
require(resolve(process.cwd(), dep));
54+
} else {
55+
require(dep);
56+
}
5257
});
53-
return require(configPath);
54-
} else {
55-
return require(configPath);
5658
}
59+
return require(configPath);
5760
})();
5861
}
5962

0 commit comments

Comments
 (0)