mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-27 01:53:48 +01:00
Resolve index files for script imports
This commit is contained in:
parent
79bb0d289a
commit
4f78fcab1b
@ -110,14 +110,18 @@ export function getModuleScript(
|
||||
throw new ModuleResolutionError(`Invalid module: "${moduleName}". Base module: "${baseModule}".`);
|
||||
}
|
||||
script = scripts.get(filename);
|
||||
if (script) {
|
||||
break;
|
||||
if (script) return script;
|
||||
}
|
||||
// If no script was found with the base name, check for a folder with index file
|
||||
for (const extension of validScriptExtensions) {
|
||||
const filename = resolveScriptFilePath(`${moduleName}/index`, baseModule, extension);
|
||||
if (!filename) {
|
||||
throw new ModuleResolutionError(`Invalid module: "${moduleName}". Base module: "${baseModule}".`);
|
||||
}
|
||||
script = scripts.get(filename);
|
||||
if (script) return script;
|
||||
}
|
||||
if (!script) {
|
||||
throw new ModuleResolutionError(`Invalid module: "${moduleName}". Base module: "${baseModule}".`);
|
||||
}
|
||||
return script;
|
||||
throw new ModuleResolutionError(`Invalid module: "${moduleName}". Base module: "${baseModule}".`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user