Skip to content

Add an option to always use system xdg-open instead of bundled version #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

deansheather
Copy link
Contributor

Adds a new option useSystemXdgOpen which allows for always using the system xdg-open command over the included version.

This is neccessary in some environments when the package thinks it can execute the included version when it actually cannot. One example is when the package is included in a binary produced by a node.js binary compiler like nbin.

@sindresorhus
Copy link
Owner

when the package is included in a binary produced by a node.js binary compiler like nbin.

Is there no way of automatically detecting that? I would really prefer to keep the options to a minimum.

@deansheather
Copy link
Contributor Author

There is a way of checking if bundled with nbin, by trying to import "nbin" (a package only included in nbin-produced binaries) and seeing if there's an id and mainFile attribute. I can open a new PR to do that if you want.

It seems that this is a problem that's appeared a few times, however, with the exclusions for Electron and Webpack. I personally think that a configurable option will allow this package to work in many more environments/setups without changes being made to the package.

@sindresorhus
Copy link
Owner

There is a way of checking if bundled with nbin, by trying to import "nbin" (a package only included in nbin-produced binaries)

Trying to import something that doesn't exist causes problems with Webpack. Any other way? Can you for example check properties on the module object?

I personally think that a configurable option will allow this package to work in
many more environments/setups without changes being made to the package.

I don't disagree, but the option is useless if you don't directly control open, for example, it's used in a dependency of a dependency. That's why automatically handling it would be good in addition to this option.

@deansheather
Copy link
Contributor Author

I don't believe there is any other way of checking if being run inside an nbin binary other than importing nbin.

@deansheather
Copy link
Contributor Author

Created a pull request on nbin for process.versions.nbin which should allow for checking if open is in an nbin binary: coder/nbin#9. Once this is merged I will close this PR and make a new one.

@notpushkin
Copy link

Perhaps a better way would be to check if path.join(__dirname, 'xdg-open') actually exists? :) (or just try to run it and fallback to the system one if it fails)

@deansheather
Copy link
Contributor Author

That does seem like a better idea actually. I've created a new PR to check if the bundled xdg-open exists and is executable. Closing as the new PR addresses my problem and the owner's concerns with this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants