Skip to content

Commit f53298b

Browse files
Merge pull request #3 from arshadkazmi42/process-name-lib
Updated to use process-name library for getting process name
2 parents e44cb9d + 1adde60 commit f53298b

File tree

7 files changed

+19
-76
lines changed

7 files changed

+19
-76
lines changed

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
const fkill = require('fkill');
22

3-
const { ProcessName } = require('./lib');
3+
const { ProcessName, ProcessNameConstants } = require('process-name');
44

55

66
const chrome = async (force) => {
7-
const procName = ProcessName.chrome();
7+
const { BROWSERS: { CHROME } } = ProcessNameConstants;
8+
const procName = ProcessName.BROWSERS[CHROME][process.platform];
89
return await fkill(procName, { force: force || true });
910
};
1011

1112

1213
const firefox = async (force) => {
13-
const procName = ProcessName.firefox();
14+
const { BROWSERS: { FIREFOX } } = ProcessNameConstants;
15+
const procName = ProcessName.BROWSERS[FIREFOX][process.platform];
1416
return await fkill(procName, { force: force || true });
1517
};
1618

lib/constants.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

lib/index.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

lib/process-name.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

package-lock.json

Lines changed: 5 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"test": "node_modules/mocha/bin/mocha tests/*"
1010
},
1111
"files": [
12-
"index.js",
13-
"lib/"
12+
"index.js"
1413
],
1514
"repository": {
1615
"type": "git",
@@ -38,6 +37,7 @@
3837
"author": "Arshad Kazmi",
3938
"license": "MIT",
4039
"dependencies": {
41-
"fkill": "^6.2.0"
40+
"fkill": "^6.2.0",
41+
"process-name": "^1.0.1"
4242
}
4343
}

tests/test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ const { expect } = require('chai');
22
const processExists = require('process-exists');
33

44
const BrKill = require('../index');
5-
const { ProcessName } = require('../lib');
5+
const { ProcessName, ProcessNameConstants } = require('process-name');
6+
const { BROWSERS: { CHROME, FIREFOX } } = ProcessNameConstants;
7+
const procNameChrome = ProcessName.BROWSERS[CHROME][process.platform];
8+
const procNameFirefox = ProcessName.BROWSERS[FIREFOX][process.platform];
69

710
const ERROR_MESSAGE_CHROME = 'killing process chrome failed: process doesn\'t exist';
811
const ERROR_MESSAGE_FIREFOX = 'killing process firefox failed: process doesn\'t exist';
@@ -15,7 +18,7 @@ describe('test kill browser process', () => {
1518
it('should kill chrome process', async () => {
1619
try {
1720
await BrKill.chrome();
18-
const exists = await processExists(ProcessName.chrome());
21+
const exists = await processExists(procNameChrome);
1922
expect(exists).to.equal(false);
2023
} catch (err) {
2124
expect(err.message.toLowerCase().includes(ERROR_MESSAGE_CHROME)).to.equal(true);
@@ -24,7 +27,7 @@ describe('test kill browser process', () => {
2427
it('should kill firefox process', async () => {
2528
try {
2629
await BrKill.firefox();
27-
const exists = await processExists(ProcessName.firefox());
30+
const exists = await processExists(procNameFirefox);
2831
expect(exists).to.equal(false);
2932
} catch (err) {
3033
expect(err.message.toLowerCase().includes(ERROR_MESSAGE_FIREFOX)).to.equal(true);

0 commit comments

Comments
 (0)