deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

Add `lookPath` function to find the path of an executable

Open wperron opened this issue 4 years ago • 8 comments

Golang's exec package has this neat LookPath function that allows finding the absolute path to an executable by it's shortname that I think would be useful in the Deno standard lib. Here's an example usage in Go:

package main

import (
	"fmt"
	"log"
	"os/exec"
)

func main() {
	path, err := exec.LookPath("fortune")
	if err != nil {
		log.Fatal("installing fortune is in your future")
	}
	fmt.Printf("fortune is available at %s\n", path)
}

Since we don't have an exec package, I propose we put this function in the fs package, though path would also be a good choice.

wperron avatar Jul 22 '21 13:07 wperron

If anyone wants to pick up where I left off, all that was left on my branch was to add tests for windows and validate that it works there, I doubt that it wouldn't. I no longer have the time (or even a Windows machine) to carry on this issue.

wperron avatar Nov 10 '21 22:11 wperron

I'd love to pick this up, but is this desirable @cjihrig?

lino-levan avatar Nov 05 '22 17:11 lino-levan

It looks like there was no opposition to https://github.com/denoland/deno_std/pull/1057, so I'm OK with it.

cc: @kt3k @bartlomieju in case the sentiment has changed in the past year.

cjihrig avatar Nov 05 '22 18:11 cjihrig

I'm still in favor.

kt3k avatar Nov 07 '22 05:11 kt3k

We're still in favour of having this. Would anyone like to pick this up?

iuioiua avatar Nov 28 '23 10:11 iuioiua

I'll do it eventually, I have everything working in a branch of mine already I just need to write some tests.

lino-levan avatar Nov 28 '23 15:11 lino-levan

Would you be able to submit a draft PR just so we can start looking at and thinking about implementation?

iuioiua avatar Nov 28 '23 18:11 iuioiua

Yeah I'll probably get it to by thursday night. Pretty busy this week.

lino-levan avatar Nov 28 '23 19:11 lino-levan