Skip to content

Commit

Permalink
xmain: Add RelPath
Browse files Browse the repository at this point in the history
  • Loading branch information
nhooyr committed Mar 5, 2023
1 parent 090ad79 commit 9eb7128
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions xmain/xmain.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"os"
"os/signal"
"path/filepath"
"syscall"
"time"

Expand Down Expand Up @@ -179,3 +180,11 @@ func (ms *State) WritePath(fp string, p []byte) error {
}
return os.WriteFile(fp, p, 0644)
}

func (ms *State) RelPath(fp string) string {
rel, err := filepath.Rel(ms.PWD, fp)
if err != nil {
return fp
}
return rel
}

0 comments on commit 9eb7128

Please sign in to comment.