kill-tabs 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +9 -4
- package/index.js +6 -2
- package/package.json +2 -1
- package/readme.md +5 -4
- package/windows.js +30 -4
package/cli.js
CHANGED
|
@@ -7,10 +7,11 @@ const cli = meow(`
|
|
|
7
7
|
$ kill-tabs
|
|
8
8
|
|
|
9
9
|
Options
|
|
10
|
-
--no-chromium
|
|
11
|
-
--no-chrome
|
|
12
|
-
--no-
|
|
13
|
-
--no-
|
|
10
|
+
--no-chromium Don't kill tabs in Chromium
|
|
11
|
+
--no-chrome Don't kill tabs in Chrome
|
|
12
|
+
--no-chrome-canary Don't kill tabs in Chrome Canary
|
|
13
|
+
--no-brave Don't kill tabs in Brave
|
|
14
|
+
--no-edge Don't kill tabs in Edge
|
|
14
15
|
`, {
|
|
15
16
|
importMeta: import.meta,
|
|
16
17
|
flags: {
|
|
@@ -22,6 +23,10 @@ const cli = meow(`
|
|
|
22
23
|
type: 'boolean',
|
|
23
24
|
default: true,
|
|
24
25
|
},
|
|
26
|
+
chromeCanary: {
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
default: true,
|
|
29
|
+
},
|
|
25
30
|
brave: {
|
|
26
31
|
type: 'boolean',
|
|
27
32
|
default: true,
|
package/index.js
CHANGED
|
@@ -4,11 +4,11 @@ import psList from 'ps-list';
|
|
|
4
4
|
import windows from './windows.js';
|
|
5
5
|
|
|
6
6
|
export default async function killTabs(options = {}) {
|
|
7
|
-
const
|
|
8
|
-
const list = await processList();
|
|
7
|
+
const list = process.platform === 'win32' ? await windows(options) : await psList();
|
|
9
8
|
|
|
10
9
|
const processes = {
|
|
11
10
|
chrome: process.platform === 'darwin' ? 'Chrome Helper' : 'chrome',
|
|
11
|
+
chromeCanary: process.platform === 'darwin' ? 'Chrome Canary Helper' : 'chrome',
|
|
12
12
|
chromium: process.platform === 'darwin' ? 'Chromium Helper' : 'chromium',
|
|
13
13
|
brave: process.platform === 'darwin' ? 'Brave Browser Helper' : 'brave',
|
|
14
14
|
edge: process.platform === 'darwin' ? 'Microsoft Edge Helper' : 'edge',
|
|
@@ -22,6 +22,10 @@ export default async function killTabs(options = {}) {
|
|
|
22
22
|
delete processes.chrome;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
if (options.chromeCanary === false) {
|
|
26
|
+
delete processes.chromeCanary;
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
if (options.brave === false) {
|
|
26
30
|
delete processes.brave;
|
|
27
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kill-tabs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Kill all Chrome tabs to improve performance, decrease battery usage, and save memory",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/kill-tabs",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"bin": "./cli.js",
|
|
15
15
|
"exports": "./index.js",
|
|
16
|
+
"sideEffects": false,
|
|
16
17
|
"engines": {
|
|
17
18
|
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
18
19
|
},
|
package/readme.md
CHANGED
|
@@ -23,10 +23,11 @@ $ kill-tabs --help
|
|
|
23
23
|
$ kill-tabs
|
|
24
24
|
|
|
25
25
|
Options
|
|
26
|
-
--no-chromium
|
|
27
|
-
--no-chrome
|
|
28
|
-
--no-
|
|
29
|
-
--no-
|
|
26
|
+
--no-chromium Don't kill tabs in Chromium
|
|
27
|
+
--no-chrome Don't kill tabs in Chrome
|
|
28
|
+
--no-chrome-canary Don't kill tabs in Chrome Canary
|
|
29
|
+
--no-brave Don't kill tabs in Brave
|
|
30
|
+
--no-edge Don't kill tabs in Edge
|
|
30
31
|
```
|
|
31
32
|
|
|
32
33
|
## API
|
package/windows.js
CHANGED
|
@@ -4,11 +4,37 @@ import execall from 'execall';
|
|
|
4
4
|
|
|
5
5
|
const TEN_MEBIBYTE = 1024 * 1024 * 10;
|
|
6
6
|
|
|
7
|
-
export default async function killTabs() {
|
|
8
|
-
const
|
|
9
|
-
const stdout = await promisify(childProcess.exec)(command, {maxBuffer: TEN_MEBIBYTE});
|
|
7
|
+
export default async function killTabs(options) {
|
|
8
|
+
const browsers = [];
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
if (options.chromium) {
|
|
11
|
+
browsers.push('Caption=\'chromium.exe\'');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (options.chrome) {
|
|
15
|
+
browsers.push('Caption=\'chrome.exe\'');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (options.chromeCanary && !options.chrome) {
|
|
19
|
+
browsers.push('Caption=\'chrome.exe\'');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (options.brave) {
|
|
23
|
+
browsers.push('Caption=\'brave.exe\'');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (options.edge) {
|
|
27
|
+
browsers.push('Caption=\'msedge.exe\'');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const arguments_ = ['process', 'where', browsers.join(' or '), 'get', 'CommandLine,ProcessId', '/format:list'];
|
|
31
|
+
const response = await promisify(childProcess.execFile)('wmic', arguments_, {maxBuffer: TEN_MEBIBYTE});
|
|
32
|
+
|
|
33
|
+
if (response.stderr && !response.stderr.includes('No Instance(s) Available.')) {
|
|
34
|
+
throw new Error('Failed to kill tabs.', {cause: new Error(response.stderr)});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return execall(/CommandLine=(.+)\s+ProcessId=(\d+)/g, response.stdout).map(element => ({
|
|
12
38
|
cmd: element.subMatches[0],
|
|
13
39
|
pid: Number.parseInt(element.subMatches[1], 10),
|
|
14
40
|
}));
|