TVDOS: path for require()

This commit is contained in:
minjaesong
2026-05-15 23:35:38 +09:00
parent e74a373605
commit 295c1f7fe2
4 changed files with 18 additions and 3 deletions

View File

@@ -147,6 +147,7 @@ _TVDOS.variables = {
LANG: "EN",
KEYBOARD: "us_qwerty",
PATH: "\\tvdos\\bin;\\home",
INCLPATH: "\\tvdos\\include;\\home",
PATHEXT: ".com;.bat;.app;.js;.alias",
HELPPATH: "\\tvdos\\help",
OS_NAME: "TSVM Disk Operating System",

View File

@@ -668,9 +668,21 @@ require = function(path) {
if (path[1] == ":") return shell.require(path)
else {
// if the path starts with ".", look for the current directory
// if the path starts with [A-Za-z0-9], look for the DOSDIR/includes
// if the path starts with [A-Za-z0-9], search through INCLPATH
if (path[0] == '.') return shell.require(shell.resolvePathInput(path).full + ".mjs")
else return shell.require(`A:${_TVDOS.variables.DOSDIR}/include/${path}.mjs`)
else {
let inclDirs = (_TVDOS.variables.INCLPATH || "").split(';').filter(function(it) { return it.length > 0 })
for (let i = 0; i < inclDirs.length; i++) {
let dir = inclDirs[i]
if (!dir.endsWith('\\') && !dir.endsWith('/')) dir += '\\'
let candidate = `${CURRENT_DRIVE}:${dir}${path}.mjs`
if (files.open(candidate).exists) return shell.require(candidate)
}
// no match found; defer to shell.require with the first entry so the error mentions a sensible path
let firstDir = inclDirs[0] || `${_TVDOS.variables.DOSDIR}\\include`
if (!firstDir.endsWith('\\') && !firstDir.endsWith('/')) firstDir += '\\'
return shell.require(`${CURRENT_DRIVE}:${firstDir}${path}.mjs`)
}
}
}

View File

@@ -1,5 +0,0 @@
/**
* Hopper is a package manager for TSVM
* Created by CuriousTorvald on 2026-04-16
*/