mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 00:46:07 +00:00
fix being able to run a script in a parent folder from a child folder
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
@@ -97,7 +98,7 @@ func __runTranslatedImport(translatedImport translatedImport, global ArObject, m
|
|||||||
return local, ArErr{}
|
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)
|
extention := filepath.Ext(realpath)
|
||||||
path := realpath
|
path := realpath
|
||||||
if extention == "" {
|
if extention == "" {
|
||||||
@@ -125,9 +126,13 @@ func translateImport(realpath string, origin string) (translatedImport, ArErr) {
|
|||||||
filepath.Join(currentPath, realpath, "init.ar"),
|
filepath.Join(currentPath, realpath, "init.ar"),
|
||||||
filepath.Join(currentPath, modules_folder, path),
|
filepath.Join(currentPath, modules_folder, path),
|
||||||
filepath.Join(currentPath, modules_folder, realpath, "init.ar"))
|
filepath.Join(currentPath, modules_folder, realpath, "init.ar"))
|
||||||
|
if topLevelOnly {
|
||||||
|
break
|
||||||
|
}
|
||||||
oldPath = currentPath
|
oldPath = currentPath
|
||||||
currentPath = filepath.Dir(currentPath)
|
currentPath = filepath.Dir(currentPath)
|
||||||
}
|
}
|
||||||
|
fmt.Println(pathsToTest)
|
||||||
}
|
}
|
||||||
var p string
|
var p string
|
||||||
var found bool
|
var found bool
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func main() {
|
|||||||
if e != nil {
|
if e != nil {
|
||||||
panic(e)
|
panic(e)
|
||||||
}
|
}
|
||||||
translated, err := translateImport(Args[0], ex)
|
translated, err := translateImport(Args[0], ex, true)
|
||||||
if err.EXISTS {
|
if err.EXISTS {
|
||||||
panicErr(err)
|
panicErr(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func parseGenericImport(code UNPARSEcode, index int, codeline []UNPARSEcode) (Ar
|
|||||||
}
|
}
|
||||||
|
|
||||||
if str, ok := toImport.(string); ok {
|
if str, ok := toImport.(string); ok {
|
||||||
resp, err := translateImport(str, filepath.Dir(filepath.ToSlash(code.path)))
|
resp, err := translateImport(str, filepath.Dir(filepath.ToSlash(code.path)), false)
|
||||||
if !err.EXISTS {
|
if !err.EXISTS {
|
||||||
importOBJ.translated = resp
|
importOBJ.translated = resp
|
||||||
importOBJ.pretranslated = true
|
importOBJ.pretranslated = true
|
||||||
@@ -102,7 +102,7 @@ func runImport(importOBJ ArImport, stack stack, stacklevel int) (any, ArErr) {
|
|||||||
return nil, ArErr{"Type Error", "import requires a string, got type '" + typeof(val) + "'", importOBJ.Line, importOBJ.Path, importOBJ.Code, true}
|
return nil, ArErr{"Type Error", "import requires a string, got type '" + typeof(val) + "'", importOBJ.Line, importOBJ.Path, importOBJ.Code, true}
|
||||||
}
|
}
|
||||||
parent := filepath.Dir(filepath.ToSlash(importOBJ.Path))
|
parent := filepath.Dir(filepath.ToSlash(importOBJ.Path))
|
||||||
translated, err = translateImport(val.(string), parent)
|
translated, err = translateImport(val.(string), parent, false)
|
||||||
if err.EXISTS {
|
if err.EXISTS {
|
||||||
if err.line == 0 {
|
if err.line == 0 {
|
||||||
err.line = importOBJ.Line
|
err.line = importOBJ.Line
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
import "circular_test"
|
import "circular_test"
|
||||||
|
term.log("epic wow")
|
||||||
@@ -1,3 +1,2 @@
|
|||||||
|
|
||||||
term.log("hello")
|
|
||||||
import "circular_import"
|
import "circular_import"
|
||||||
|
term.log("hello")
|
||||||
Reference in New Issue
Block a user