mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 03:23: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}".`);
|
throw new ModuleResolutionError(`Invalid module: "${moduleName}". Base module: "${baseModule}".`);
|
||||||
}
|
}
|
||||||
script = scripts.get(filename);
|
script = scripts.get(filename);
|
||||||
if (script) {
|
if (script) return script;
|
||||||
break;
|
}
|
||||||
|
// 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}".`);
|
||||||
throw new ModuleResolutionError(`Invalid module: "${moduleName}". Base module: "${baseModule}".`);
|
|
||||||
}
|
|
||||||
return script;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user