default-browser
Advanced tools
Comparing version 2.0.1 to 3.0.0
20
index.js
@@ -1,6 +0,6 @@ | ||
'use strict'; | ||
const defaultBrowserId = require('default-browser-id'); | ||
const bundleName = require('bundle-name'); | ||
import defaultBrowserId from 'default-browser-id'; | ||
import bundleName from 'bundle-name'; | ||
import windows from './windows.js'; | ||
module.exports = () => { | ||
export default async function defaultBrowser() { | ||
if (process.platform === 'linux') { | ||
@@ -11,6 +11,12 @@ return require('xdg-default-browser')(); | ||
if (process.platform === 'darwin') { | ||
return defaultBrowserId().then(id => bundleName(id).then(name => ({name, id}))); | ||
const id = await defaultBrowserId(); | ||
const name = await bundleName(id); | ||
return {name, id}; | ||
} | ||
return Promise.reject(new Error('Only macOS and Linux are supported')); | ||
}; | ||
if (process.platform === 'win32') { | ||
return windows(); | ||
} | ||
throw new Error('Only macOS, Linux, and Windows are supported'); | ||
} |
{ | ||
"name": "default-browser", | ||
"version": "2.0.1", | ||
"description": "Get the default browser", | ||
"license": "MIT", | ||
"repository": "sindresorhus/default-browser", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"macos", | ||
"osx", | ||
"linux", | ||
"browser", | ||
"default", | ||
"plist", | ||
"web", | ||
"bundle", | ||
"bundleid", | ||
"id", | ||
"identifier", | ||
"uti", | ||
"CFBundleName", | ||
"applescript" | ||
], | ||
"dependencies": { | ||
"bundle-name": "^2.0.1", | ||
"default-browser-id": "^2.0.0", | ||
"xdg-default-browser": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
"name": "default-browser", | ||
"version": "3.0.0", | ||
"description": "Get the default browser", | ||
"license": "MIT", | ||
"repository": "sindresorhus/default-browser", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=12" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"windows.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"macos", | ||
"linux", | ||
"browser", | ||
"default", | ||
"plist", | ||
"web", | ||
"bundle", | ||
"bundleid", | ||
"id", | ||
"identifier", | ||
"uti", | ||
"cfbundlename", | ||
"applescript" | ||
], | ||
"dependencies": { | ||
"bundle-name": "^3.0.0", | ||
"default-browser-id": "^3.0.0", | ||
"execa": "^5.0.0", | ||
"xdg-default-browser": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^3.15.0", | ||
"tsd": "^0.14.0", | ||
"xo": "^0.38.2" | ||
} | ||
} |
@@ -1,5 +0,6 @@ | ||
# default-browser [![Build Status](https://travis-ci.org/sindresorhus/default-browser.svg?branch=master)](https://travis-ci.org/sindresorhus/default-browser) | ||
# default-browser | ||
> Get the default browser (macOS and Linux) | ||
> Get the default browser | ||
Works on macOS, Linux, and Windows. | ||
@@ -9,25 +10,16 @@ ## Install | ||
``` | ||
$ npm install --save default-browser | ||
$ npm install default-browser | ||
``` | ||
## Usage | ||
```js | ||
const defaultBrowser = require('default-browser'); | ||
import defaultBrowser from 'default-browser'; | ||
defaultBrowser().then(browser => { | ||
console.log(browser); | ||
//=> {name: 'Safari', id: 'com.apple.Safari'} | ||
}); | ||
console.log(await defaultBrowser()); | ||
//=> {name: 'Safari', id: 'com.apple.Safari'} | ||
``` | ||
## Related | ||
- [default-browser-cli](https://github.com/sindresorhus/default-browser-cli) - CLI for this module | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) | ||
- [default-browser-cli](https://github.com/sindresorhus/default-browser-cli) - CLI for this package |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4940
6
69
Yes
4
3
25
+ Addedexeca@^5.0.0
+ Addedbplist-parser@0.2.0(transitive)
+ Addedbundle-name@3.0.0(transitive)
+ Addedcross-spawn@7.0.5(transitive)
+ Addeddefault-browser-id@3.0.0(transitive)
+ Addedexeca@5.1.1(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedhuman-signals@2.1.0(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addednpm-run-path@4.0.1(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedrun-applescript@5.0.0(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstrip-final-newline@2.0.0(transitive)
+ Addeduntildify@4.0.0(transitive)
+ Addedwhich@2.0.2(transitive)
- Removedbplist-parser@0.1.1(transitive)
- Removedbundle-name@2.0.1(transitive)
- Removeddefault-browser-id@2.0.0(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedpify@2.3.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedrun-applescript@2.1.0(transitive)
- Removeduntildify@2.1.0(transitive)
Updatedbundle-name@^3.0.0
Updateddefault-browser-id@^3.0.0
Updatedxdg-default-browser@^2.1.0