Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions internal/bundled/noembed.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ package bundled
import (
"fmt"
"os"
"path/filepath"
"sync"
"testing"

"github.com/microsoft/typescript-go/internal/tspath"
"github.com/microsoft/typescript-go/internal/vfs"
"github.com/microsoft/typescript-go/internal/vfs/osvfs"
)

const embedded = false
Expand All @@ -24,11 +24,9 @@ var executableDir = sync.OnceValue(func() string {
if err != nil {
panic(fmt.Sprintf("bundled: failed to get executable path: %v", err))
}
exe, err = filepath.EvalSymlinks(exe)
if err != nil {
panic(fmt.Sprintf("bundled: failed to evaluate symlinks: %v", err))
}
return filepath.Dir(exe)
exe = tspath.NormalizeSlashes(exe)
exe = osvfs.FS().Realpath(exe)
return tspath.GetDirectoryPath(exe)
})

var libPath = sync.OnceValue(func() string {
Expand All @@ -37,10 +35,10 @@ var libPath = sync.OnceValue(func() string {
}
dir := executableDir()

libdts := filepath.Join(dir, "lib.d.ts")
if _, err := os.Stat(libdts); err != nil {
libdts := tspath.CombinePaths(dir, "lib.d.ts")
if info := osvfs.FS().Stat(libdts); info == nil {
panic(fmt.Sprintf("bundled: %v does not exist; this executable may be misplaced", libdts))
}

return tspath.NormalizeSlashes(dir)
return dir
})