From 295c1f7fe2f83504162b3ba4ad4112c262cc93e8 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Fri, 15 May 2026 23:35:38 +0900 Subject: [PATCH] TVDOS: path for require() --- assets/disk0/AUTOEXEC.BAT | 3 ++- assets/disk0/{tvdos => hopper}/bin/hopper.js | 1 + assets/disk0/tvdos/TVDOS.SYS | 1 + assets/disk0/tvdos/bin/command.js | 16 ++++++++++++++-- 4 files changed, 18 insertions(+), 3 deletions(-) rename assets/disk0/{tvdos => hopper}/bin/hopper.js (67%) diff --git a/assets/disk0/AUTOEXEC.BAT b/assets/disk0/AUTOEXEC.BAT index bf9d57e..103d9bb 100644 --- a/assets/disk0/AUTOEXEC.BAT +++ b/assets/disk0/AUTOEXEC.BAT @@ -1,7 +1,8 @@ echo "Starting TVDOS..." 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 rem this line specifies which shell to be presented after the boot precess: diff --git a/assets/disk0/tvdos/bin/hopper.js b/assets/disk0/hopper/bin/hopper.js similarity index 67% rename from assets/disk0/tvdos/bin/hopper.js rename to assets/disk0/hopper/bin/hopper.js index 8ec85a1..da226cb 100644 --- a/assets/disk0/tvdos/bin/hopper.js +++ b/assets/disk0/hopper/bin/hopper.js @@ -3,3 +3,4 @@ * Created by CuriousTorvald on 2026-04-16 */ +println("Hopper - Package manager for TSVM") \ No newline at end of file diff --git a/assets/disk0/tvdos/TVDOS.SYS b/assets/disk0/tvdos/TVDOS.SYS index 327c4ea..3796c70 100644 --- a/assets/disk0/tvdos/TVDOS.SYS +++ b/assets/disk0/tvdos/TVDOS.SYS @@ -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", diff --git a/assets/disk0/tvdos/bin/command.js b/assets/disk0/tvdos/bin/command.js index 99c1185..23479d8 100644 --- a/assets/disk0/tvdos/bin/command.js +++ b/assets/disk0/tvdos/bin/command.js @@ -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`) + } } }