Subash / Subash/detect-browsers
Allow getAvailableBrowsers to pass options to which module
@Subash is already working on this.
Since Nov 16, 2019.
- Dominant language
- TypeScript
- Stars
- 3
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Hi, thanks for this library!
I'm playing with it inside an Electron app and I've encountered a minor issue (with Electron). Short story: the Electron renderer process.env doesn't inherit the variables from the main process on Linux, which are available through renderer.process.env. So I have to use the which options to pass the PATH env variable.
I would basically like to do something like:
let opt = { path: remote.process.env.PATH };
detectBrowsers.getAvailableBrowsers(opt);
Which can be achieved just adding the optional parameter to getAvailableBrowsers:
async function getExecutable(browser, opt) {
const execs = browsers[browser];
if(!execs || !execs[process.platform]) return;
for(const exec of execs[process.platform]) {
const executable = await which(exec, opt).catch(()=>{});
if(executable) return executable;
}
}
async function getAvailableBrowsers(opt) {
const list = [];
for(const browser of Object.keys(browsers)) {
const exec = await getExecutable(browser, opt);
if(exec) list.push({ browser, path: exec });
}
return list;
}
I guess passing options to the which module could be useful in some other cases, so it would be nice if a future release included the ability to do it somehow.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.