Fixed require paths
Previously, relative require paths would be resolved based on the current working directory. They are now resolved based on the path of the module.
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
package parser
|
||||
|
||||
import "os"
|
||||
import "path/filepath"
|
||||
import "git.tebibyte.media/arf/arf/lexer"
|
||||
import "git.tebibyte.media/arf/arf/infoerr"
|
||||
|
||||
// parseMeta parsese the metadata header at the top of an arf file.
|
||||
func (parser *parsingOperation) parseMeta () (err error) {
|
||||
cwd, _ := os.Getwd()
|
||||
|
||||
for {
|
||||
err = parser.expect (
|
||||
lexer.TokenKindName,
|
||||
@@ -37,7 +34,7 @@ func (parser *parsingOperation) parseMeta () (err error) {
|
||||
case "require":
|
||||
// if import path is relative, get absolute path.
|
||||
if value[0] == '.' {
|
||||
value = filepath.Join(cwd, value)
|
||||
value = filepath.Join(parser.modulePath, value)
|
||||
} else if value[0] != '/' {
|
||||
// TODO: get arf import path from an env
|
||||
// variable, and default to this if not found.
|
||||
|
||||
Reference in New Issue
Block a user