Comparing version 2.0.3 to 3.0.0
52
cli.js
@@ -7,40 +7,26 @@ #!/usr/bin/env node | ||
var cli = meow({ | ||
help: [ | ||
'Example', | ||
' $ bluetooth', | ||
' $ bluetooth on', | ||
' $ bluetooth off' | ||
] | ||
}); | ||
var cli = meow([ | ||
'Example', | ||
' $ bluetooth', | ||
' $ bluetooth on', | ||
' $ bluetooth off' | ||
]); | ||
if (!cli.input.length) { | ||
bluetooth.isOn(function (err, state) { | ||
if (err) { | ||
console.error(err.message); | ||
process.exit(3); | ||
} | ||
if (cli.input.length) { | ||
if (cli.input[0] !== 'on' && cli.input[0] !== 'off') { | ||
console.log('Set bluetooth state to either `on` or `off`'); | ||
process.exit(3); | ||
} | ||
var state = cli.input[0] === 'on'; | ||
bluetooth.toggle(state).then(function () { | ||
console.log(state ? logSymbols.success + ' On' : logSymbols.error + ' Off'); | ||
process.exit(state ? 0 : 1); | ||
}); | ||
return; | ||
} else { | ||
bluetooth.isOn().then(function (state) { | ||
console.log(state ? logSymbols.success + ' On' : logSymbols.error + ' Off'); | ||
process.exit(state ? 0 : 1); | ||
}); | ||
} | ||
if (cli.input[0] !== 'on' && cli.input[0] !== 'off') { | ||
console.log('Set bluetooth state to either `on` or `off`'); | ||
process.exit(3); | ||
} | ||
var state = cli.input[0] === 'on'; | ||
bluetooth.toggle(state, function (err) { | ||
if (err) { | ||
console.error(err.message); | ||
process.exit(3); | ||
} | ||
console.log(state ? logSymbols.success + ' On' : logSymbols.error + ' Off'); | ||
process.exit(state ? 0 : 1); | ||
}); |
{ | ||
"name": "bluetooth", | ||
"version": "2.0.3", | ||
"version": "3.0.0", | ||
"description": "Get or set Bluetooth state.", | ||
@@ -17,3 +17,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "xo && node test.js" | ||
"test": "xo && ava" | ||
}, | ||
@@ -36,8 +36,13 @@ "files": [ | ||
"meow": "^3.3.0", | ||
"osx-bluetooth": "^2.0.0" | ||
"osx-bluetooth": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.2.0", | ||
"xo": "^0.6.1" | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"ignores": [ | ||
"test.js" | ||
] | ||
} | ||
} |
@@ -18,5 +18,5 @@ # bluetooth [![Build Status](https://travis-ci.org/gillstrom/bluetooth.svg?branch=master)](https://travis-ci.org/gillstrom/bluetooth) | ||
```js | ||
var bluetooth = require('bluetooth'); | ||
const bluetooth = require('bluetooth'); | ||
bluetooth.isOn(function (err, state) { | ||
bluetooth.isOn().then(state => { | ||
console.log(state); | ||
@@ -26,11 +26,11 @@ //=> false | ||
bluetooth.on(function (err) { | ||
bluetooth.on().then(state => { | ||
console.log('Bluetooth state changed to on'); | ||
}); | ||
bluetooth.off(function (err) { | ||
bluetooth.off().then(state => { | ||
console.log('Bluetooth state changed to off'); | ||
}); | ||
bluetooth.toggle(function (err) { | ||
bluetooth.toggle().then(state => { | ||
console.log('Bluetooth state changed to on'); | ||
@@ -59,17 +59,17 @@ }); | ||
### .isOn(callback) | ||
### .isOn() | ||
Check if bluetooth is on or off. | ||
Check if bluetooth is on or off. Returns a promise for a `boolean`. | ||
### .on(callback) | ||
### .on() | ||
Turn bluetooth on. | ||
Turn bluetooth on. Returns a promise. | ||
### .off(callback) | ||
### .off() | ||
Turn bluetooth off. | ||
Turn bluetooth off. Returns a promise. | ||
### .toggle([force], callback) | ||
### .toggle([force]) | ||
Toggle the bluetooth state. | ||
Toggle the bluetooth state. Returns a promise. | ||
@@ -76,0 +76,0 @@ #### force |
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
3885
29
+ Addedosx-bluetooth@3.0.0(transitive)
+ Addedpinkie@1.0.0(transitive)
+ Addedpinkie-promise@1.0.0(transitive)
- Removedosx-bluetooth@2.0.0(transitive)
Updatedosx-bluetooth@^3.0.0