Skip to content

Commit e5e7738

Browse files
committed
refacto: use promises (breaking)
* use Promises rather than function/callback * drop pify as a dependency * v4.0.0
1 parent fa9c387 commit e5e7738

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
'use strict';
22

33
const {exec} = require('child_process');
4-
const pify = require('pify');
54

6-
const f = function (cb) {
5+
module.exports = new Promise((resolve, reject) => {
76
exec('ps -e | grep -E \'unity-panel\'', (error, stdout) => {
87
if (error) {
9-
cb(null, false);
8+
if (error.killed === false && error.signal === null) {
9+
resolve(false);
10+
}
11+
12+
reject(error);
1013
}
1114

1215
if ((stdout).length > 0) {
13-
cb(null, true);
16+
resolve(true);
1417
}
1518

16-
cb(null, false);
19+
resolve(false);
1720
});
18-
};
19-
20-
module.exports = pify(f);
21+
});

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "is-unity",
3-
"version": "3.0.0",
3+
"version": "4.0.0",
44
"description": "Check if the current session runs Unity desktop",
55
"license": "MIT",
66
"repository": "t1st3/is-unity",
@@ -26,9 +26,7 @@
2626
"detect",
2727
"check"
2828
],
29-
"dependencies": {
30-
"pify": "^4.0.0"
31-
},
29+
"dependencies": {},
3230
"devDependencies": {
3331
"ava": "^2.3.0",
3432
"nyc": "^14.1.1",

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $ npm install --save is-unity
1515
```js
1616
const isUnity = require('is-unity');
1717

18-
isUnity().then(data => {
18+
isUnity.then(data => {
1919
console.log(data);
2020
//=> true or false
2121
});

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import test from 'ava';
22
import isUnity from '.';
33

44
test('is-unity', async t => {
5-
t.is(await isUnity(), false);
5+
t.is(await isUnity, false);
66
});

0 commit comments

Comments
 (0)