Improve filepath resolution for relative paths

This commit is contained in:
2024-09-11 19:43:43 +02:00
parent 290e6fdaba
commit 205f8314d6
3 changed files with 16 additions and 12 deletions

View File

@@ -22,7 +22,7 @@ func (instruction *LinkInstruction) String() string {
return fmt.Sprintf("%s%s%s%s%s%s%s%s%s%s%s%s%s", SourceColor, instruction.Source, DefaultColor, deliminer, TargetColor, instruction.Target, DefaultColor, deliminer, strconv.FormatBool(instruction.Force), deliminer, strconv.FormatBool(instruction.Hard), deliminer, strconv.FormatBool(instruction.Delete))
}
func ParseInstruction(line string) (LinkInstruction, error) {
func ParseInstruction(line, workdir string) (LinkInstruction, error) {
line = strings.TrimSpace(line)
parts := strings.Split(line, deliminer)
instruction := LinkInstruction{}
@@ -51,8 +51,8 @@ func ParseInstruction(line string) (LinkInstruction, error) {
instruction.Source, _ = ConvertHome(instruction.Source)
instruction.Target, _ = ConvertHome(instruction.Target)
instruction.Source = NormalizePath(instruction.Source)
instruction.Target = NormalizePath(instruction.Target)
instruction.Source = NormalizePath(instruction.Source, workdir)
instruction.Target = NormalizePath(instruction.Target, workdir)
return instruction, nil
}