subash / detect-browsers Goto Github PK
View Code? Open in Web Editor NEWDetect browsers installed on a system.
Detect browsers installed on a system.
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.
I cannot use your NPM package because it uses ES2015/ES6 modules. Please use something like Babel or Buble to transpile your modules to commonjs modules before publishing on NPM!
Right now, I can only use version 2.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.