mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-09 06:34:04 +09:00
TVDOS: path for require()
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
echo "Starting TVDOS..."
|
echo "Starting TVDOS..."
|
||||||
|
|
||||||
rem put set-xxx commands here:
|
rem put set-xxx commands here:
|
||||||
set PATH=\tvdos\installer;\tvdos\tuidev;\tbas;$PATH
|
set PATH=\tvdos\installer;\tvdos\tuidev;\tbas;\hopper\bin;$PATH
|
||||||
|
set INCLPATH=\hopper\include;$INCLPATH
|
||||||
set KEYBOARD=us_colemak
|
set KEYBOARD=us_colemak
|
||||||
|
|
||||||
rem this line specifies which shell to be presented after the boot precess:
|
rem this line specifies which shell to be presented after the boot precess:
|
||||||
|
|||||||
@@ -3,3 +3,4 @@
|
|||||||
* Created by CuriousTorvald on 2026-04-16
|
* Created by CuriousTorvald on 2026-04-16
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
println("Hopper - Package manager for TSVM")
|
||||||
@@ -147,6 +147,7 @@ _TVDOS.variables = {
|
|||||||
LANG: "EN",
|
LANG: "EN",
|
||||||
KEYBOARD: "us_qwerty",
|
KEYBOARD: "us_qwerty",
|
||||||
PATH: "\\tvdos\\bin;\\home",
|
PATH: "\\tvdos\\bin;\\home",
|
||||||
|
INCLPATH: "\\tvdos\\include;\\home",
|
||||||
PATHEXT: ".com;.bat;.app;.js;.alias",
|
PATHEXT: ".com;.bat;.app;.js;.alias",
|
||||||
HELPPATH: "\\tvdos\\help",
|
HELPPATH: "\\tvdos\\help",
|
||||||
OS_NAME: "TSVM Disk Operating System",
|
OS_NAME: "TSVM Disk Operating System",
|
||||||
|
|||||||
@@ -668,9 +668,21 @@ require = function(path) {
|
|||||||
if (path[1] == ":") return shell.require(path)
|
if (path[1] == ":") return shell.require(path)
|
||||||
else {
|
else {
|
||||||
// if the path starts with ".", look for the current directory
|
// 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")
|
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`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user