default-browser
Advanced tools
Comparing version 1.0.0 to 2.0.0
29
index.js
'use strict'; | ||
var defaultBrowserId = require('default-browser-id'); | ||
var bundleName = require('bundle-name'); | ||
const defaultBrowserId = require('default-browser-id'); | ||
const bundleName = require('bundle-name'); | ||
module.exports = function (cb) { | ||
defaultBrowserId(function (err, id) { | ||
if (err) { | ||
cb(err); | ||
return; | ||
} | ||
module.exports = () => { | ||
if (process.platform === 'linux') { | ||
return require('xdg-default-browser')(); | ||
} | ||
bundleName(id, function (err, name) { | ||
if (err) { | ||
cb(err); | ||
return; | ||
} | ||
if (process.platform !== 'darwin') { | ||
throw new Error('Only OS X and Linux are supported'); | ||
} | ||
cb(null, { | ||
name: name, | ||
id: id | ||
}); | ||
}); | ||
}); | ||
return defaultBrowserId().then(id => bundleName(id).then(name => ({name, id}))); | ||
}; |
{ | ||
"name": "default-browser", | ||
"version": "1.0.0", | ||
"description": "Get the default browser (OS X)", | ||
"version": "2.0.0", | ||
"description": "Get the default browser", | ||
"license": "MIT", | ||
@@ -10,23 +10,16 @@ "repository": "sindresorhus/default-browser", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "http://sindresorhus.com" | ||
"url": "sindresorhus.com" | ||
}, | ||
"bin": { | ||
"default-browser": "cli.js" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
"os": [ | ||
"darwin" | ||
], | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"cli.js" | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"osx", | ||
"mac", | ||
"linux", | ||
"browser", | ||
@@ -42,13 +35,16 @@ "default", | ||
"CFBundleName", | ||
"cli", | ||
"bin", | ||
"applescript" | ||
], | ||
"dependencies": { | ||
"bundle-name": "^1.0.0", | ||
"default-browser-id": "^1.0.0" | ||
"bundle-name": "^2.0.1", | ||
"default-browser-id": "^2.0.0", | ||
"xdg-default-browser": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*" | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
} |
# default-browser [![Build Status](https://travis-ci.org/sindresorhus/default-browser.svg?branch=master)](https://travis-ci.org/sindresorhus/default-browser) | ||
> Get the default browser (OS X) | ||
> Get the default browser (OS X and Linux) | ||
@@ -8,3 +8,3 @@ | ||
```bash | ||
``` | ||
$ npm install --save default-browser | ||
@@ -17,7 +17,7 @@ ``` | ||
```js | ||
var defaultBrowser = require('default-browser'); | ||
const defaultBrowser = require('default-browser'); | ||
defaultBrowser(function (err, browser) { | ||
defaultBrowser().then(browser => { | ||
console.log(browser); | ||
//=> { name: 'Safari', id: 'com.apple.Safari' } | ||
//=> {name: 'Safari', id: 'com.apple.Safari'} | ||
}); | ||
@@ -27,21 +27,9 @@ ``` | ||
## CLI | ||
## Related | ||
You can also use it as a CLI app by installing it globally: | ||
- [default-browser-cli](https://github.com/sindresorhus/default-browser-cli) - CLI for this module | ||
```bash | ||
$ npm install --global default-browser | ||
``` | ||
### Usage | ||
```bash | ||
$ default-browser | ||
``` | ||
Which will for example output `Safari`. | ||
## License | ||
[MIT](http://opensource.org/licenses/MIT) © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
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
2967
3
2
12
33
+ Addedxdg-default-browser@^2.0.0
+ Addedbundle-name@2.0.1(transitive)
+ Addedcross-spawn-async@2.2.5(transitive)
+ Addeddefault-browser-id@2.0.0(transitive)
+ Addedexeca@0.2.2(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addednpm-run-path@1.0.0(transitive)
+ Addedpath-key@1.0.0(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedrun-applescript@2.1.0(transitive)
+ Addedstrip-eof@1.0.0(transitive)
+ Addedtitleize@1.0.1(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedxdg-default-browser@2.1.0(transitive)
+ Addedyallist@2.1.2(transitive)
- Removedarray-find-index@1.0.2(transitive)
- Removedbundle-name@1.0.1(transitive)
- Removedcamelcase@2.1.1(transitive)
- Removedcamelcase-keys@2.1.0(transitive)
- Removedcurrently-unhandled@0.4.1(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddefault-browser-id@1.0.4(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedfind-up@1.1.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-stdin@4.0.1(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedindent-string@2.1.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-finite@1.1.0(transitive)
- Removedis-utf8@0.2.1(transitive)
- Removedload-json-file@1.1.0(transitive)
- Removedloud-rejection@1.6.0(transitive)
- Removedmap-obj@1.0.1(transitive)
- Removedmeow@3.7.0(transitive)
- Removedminimist@1.2.8(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpath-exists@2.1.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@1.1.0(transitive)
- Removedread-pkg@1.1.0(transitive)
- Removedread-pkg-up@1.0.1(transitive)
- Removedredent@1.0.0(transitive)
- Removedrepeating@2.0.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedrun-applescript@1.0.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedstrip-bom@2.0.0(transitive)
- Removedstrip-indent@1.0.1(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtrim-newlines@1.0.0(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
Updatedbundle-name@^2.0.1
Updateddefault-browser-id@^2.0.0