fix being able to run a script in a parent folder from a child folder

This commit is contained in:
2024-05-29 23:15:49 +01:00
parent 37a3d56b5f
commit f0876bd5ac
5 changed files with 13 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ package main
import (
"bufio"
"fmt"
"os"
"path/filepath"
)
@@ -97,7 +98,7 @@ func __runTranslatedImport(translatedImport translatedImport, global ArObject, m
return local, ArErr{}
}
func translateImport(realpath string, origin string) (translatedImport, ArErr) {
func translateImport(realpath string, origin string, topLevelOnly bool) (translatedImport, ArErr) {
extention := filepath.Ext(realpath)
path := realpath
if extention == "" {
@@ -125,9 +126,13 @@ func translateImport(realpath string, origin string) (translatedImport, ArErr) {
filepath.Join(currentPath, realpath, "init.ar"),
filepath.Join(currentPath, modules_folder, path),
filepath.Join(currentPath, modules_folder, realpath, "init.ar"))
if topLevelOnly {
break
}
oldPath = currentPath
currentPath = filepath.Dir(currentPath)
}
fmt.Println(pathsToTest)
}
var p string
var found bool