command-exists icon indicating copy to clipboard operation
command-exists copied to clipboard

Feature request: Mac support

Open rebelvg opened this issue 8 years ago • 7 comments
trafficstars

Great repo, but it really lacks mac support.

On mac you can exec

which command_name

and it will return you the path.

I can probably do a PR if you're busy. Let me know.

rebelvg avatar Sep 11 '17 23:09 rebelvg

Thanks @rebelvg!

Do you have a specific case of things failing on mac? I develop on OSX and the test suite passes as expected locally.

I'm happy to accept a PR if there's something broken

mathisonian avatar Sep 11 '17 23:09 mathisonian

I was looking at the code and assumed that if the code didn't have mac specific check it wouldn't work correctly on mac. I was wrong. My friend on mac os just double checked and unix command

command -v command_name

returns the path correctly, but for some reason the module fails to find the command in question and returns false.

rebelvg avatar Sep 11 '17 23:09 rebelvg

Ah okay, that definitely sounds like a bug. Any info on the offending command would be appreciated - and if you want to take a stab at a PR to fix that would be great!

mathisonian avatar Sep 11 '17 23:09 mathisonian

My friend on OSX just did a few more tests. If he's running the program from root the module works and returns true. But if the program is running from user, it seems that the module can't execute the command -v. Not sure if that can be called a bug (I mean, it's a correct behavior from unix-like system point of view). I'm not really familiar with OSX, is there a way around this? Thanks.

rebelvg avatar Sep 12 '17 00:09 rebelvg

Just to reiterate so I understand - the problem is that the user that is running the node.js script doesn't actually have the ability to execute command -v. But they do have access to the command that they are checking for?

Hmm...

Is the user able to execute which? If so we could conditionally use that instead, but I'm not sure why they'd be able to execute which, but not command

mathisonian avatar Sep 12 '17 00:09 mathisonian

Okay, let me elaborate.

I'm making a nodejs app using electron on windows. I need to check if a certain command is registered in the system. Running your module, works great.

My friend on OSX runs my electron app and on his end the command-exists module fails if the app is running from the user. But works correctly if app is running as root. command -v and which work correctly on his machine when running from terminal.

rebelvg avatar Sep 12 '17 00:09 rebelvg

I found a solution and it's one of those weird ones. Basically, here's an issue I found. https://github.com/electron/electron/issues/7688 And there's link to the solution down in the comments. https://github.com/sindresorhus/fix-path

rebelvg avatar Sep 12 '17 01:09 rebelvg