kill-tabs 3.1.0 → 4.0.1
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 +8 -8
- package/index.js +14 -16
- package/license +1 -1
- package/package.json +13 -11
- package/readme.md +8 -13
- package/windows.js +8 -9
package/cli.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const killTabs = require('.');
|
|
2
|
+
import meow from 'meow';
|
|
3
|
+
import killTabs from './index.js';
|
|
5
4
|
|
|
6
5
|
const cli = meow(`
|
|
7
6
|
Usage
|
|
@@ -12,20 +11,21 @@ const cli = meow(`
|
|
|
12
11
|
--no-chrome Don't kill tabs in Chrome
|
|
13
12
|
--no-brave Don't kill tabs in Brave
|
|
14
13
|
`, {
|
|
14
|
+
importMeta: import.meta,
|
|
15
15
|
flags: {
|
|
16
16
|
chromium: {
|
|
17
17
|
type: 'boolean',
|
|
18
|
-
default: true
|
|
18
|
+
default: true,
|
|
19
19
|
},
|
|
20
20
|
chrome: {
|
|
21
21
|
type: 'boolean',
|
|
22
|
-
default: true
|
|
22
|
+
default: true,
|
|
23
23
|
},
|
|
24
24
|
brave: {
|
|
25
25
|
type: 'boolean',
|
|
26
|
-
default: true
|
|
27
|
-
}
|
|
28
|
-
}
|
|
26
|
+
default: true,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
killTabs(cli.flags);
|
package/index.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import fkill from 'fkill';
|
|
3
|
+
import psList from 'ps-list';
|
|
4
|
+
import windows from './windows.js';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
module.exports = async (options = {}) => {
|
|
10
|
-
const list = await psList();
|
|
6
|
+
export default async function killTabs(options = {}) {
|
|
7
|
+
const processList = process.platform === 'win32' ? windows : psList;
|
|
8
|
+
const list = await processList();
|
|
11
9
|
|
|
12
10
|
const processes = {
|
|
13
11
|
chrome: process.platform === 'darwin' ? 'Chrome Helper' : 'chrome',
|
|
14
12
|
chromium: process.platform === 'darwin' ? 'Chromium Helper' : 'chromium',
|
|
15
|
-
brave: process.platform === 'darwin' ? 'Brave Helper' : 'brave'
|
|
13
|
+
brave: process.platform === 'darwin' ? 'Brave Browser Helper' : 'brave',
|
|
16
14
|
};
|
|
17
15
|
|
|
18
16
|
if (options.chromium === false) {
|
|
@@ -28,12 +26,12 @@ module.exports = async (options = {}) => {
|
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
const pids = list
|
|
31
|
-
.filter(
|
|
32
|
-
Object.keys(processes).some(name =>
|
|
33
|
-
|
|
34
|
-
!
|
|
29
|
+
.filter(process_ =>
|
|
30
|
+
Object.keys(processes).some(name => process_.cmd.includes(processes[name]))
|
|
31
|
+
&& process_.cmd.includes('--type=renderer')
|
|
32
|
+
&& !process_.cmd.includes('--extension-process'),
|
|
35
33
|
)
|
|
36
|
-
.map(
|
|
34
|
+
.map(process_ => process_.pid);
|
|
37
35
|
|
|
38
36
|
return fkill(pids, {force: true});
|
|
39
|
-
}
|
|
37
|
+
}
|
package/license
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kill-tabs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
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",
|
|
7
|
+
"funding": "https://github.com/sponsors/sindresorhus",
|
|
7
8
|
"author": {
|
|
8
9
|
"name": "Sindre Sorhus",
|
|
9
10
|
"email": "sindresorhus@gmail.com",
|
|
10
|
-
"url": "sindresorhus.com"
|
|
11
|
+
"url": "https://sindresorhus.com"
|
|
11
12
|
},
|
|
12
|
-
"
|
|
13
|
+
"type": "module",
|
|
14
|
+
"bin": "./cli.js",
|
|
15
|
+
"exports": "./index.js",
|
|
13
16
|
"engines": {
|
|
14
|
-
"node": ">=
|
|
17
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
15
18
|
},
|
|
16
19
|
"scripts": {
|
|
17
20
|
"test": "xo && ava"
|
|
@@ -33,14 +36,13 @@
|
|
|
33
36
|
"performance"
|
|
34
37
|
],
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"execall": "^
|
|
37
|
-
"fkill": "^
|
|
38
|
-
"meow": "^
|
|
39
|
-
"
|
|
40
|
-
"ps-list": "^6.3.0"
|
|
39
|
+
"execall": "^3.0.0",
|
|
40
|
+
"fkill": "^8.0.0",
|
|
41
|
+
"meow": "^10.1.1",
|
|
42
|
+
"ps-list": "^7.2.0"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
|
-
"ava": "^
|
|
44
|
-
"xo": "^0.
|
|
45
|
+
"ava": "^3.15.0",
|
|
46
|
+
"xo": "^0.45.0"
|
|
45
47
|
}
|
|
46
48
|
}
|
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# kill-tabs
|
|
1
|
+
# kill-tabs
|
|
2
2
|
|
|
3
3
|
> Kill all Chrome tabs to improve performance, decrease battery usage, and save memory
|
|
4
4
|
|
|
@@ -10,11 +10,10 @@ I'm a [tab-abuser](https://cloud.githubusercontent.com/assets/170270/8513617/429
|
|
|
10
10
|
|
|
11
11
|
When you run `kill-tabs` the Chrome tab processes are killed, which means they will no longer take up system resources, but they will still be in your Chrome window, just as crashed. When you want one back you just reload the tab.
|
|
12
12
|
|
|
13
|
-
|
|
14
13
|
## CLI
|
|
15
14
|
|
|
16
|
-
```
|
|
17
|
-
|
|
15
|
+
```sh
|
|
16
|
+
npm install --global kill-tabs
|
|
18
17
|
```
|
|
19
18
|
|
|
20
19
|
```
|
|
@@ -29,23 +28,19 @@ $ kill-tabs --help
|
|
|
29
28
|
--no-brave Don't kill tabs in Brave
|
|
30
29
|
```
|
|
31
30
|
|
|
32
|
-
|
|
33
31
|
## API
|
|
34
32
|
|
|
35
|
-
```
|
|
36
|
-
|
|
33
|
+
```sh
|
|
34
|
+
npm install kill-tabs
|
|
37
35
|
```
|
|
38
36
|
|
|
39
37
|
```js
|
|
40
|
-
|
|
38
|
+
import killTabs from 'kill-tabs';
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
console.log('Killed tabs');
|
|
45
|
-
})();
|
|
40
|
+
await killTabs();
|
|
41
|
+
console.log('Killed tabs');
|
|
46
42
|
```
|
|
47
43
|
|
|
48
|
-
|
|
49
44
|
## Tip
|
|
50
45
|
|
|
51
46
|
You can use the [Reload All Tabs](https://chrome.google.com/webstore/detail/reload-all-tabs/lgpdljdpanfecnpindkbnikegohoobci) Chrome extension to easily reload all the tabs.
|
package/windows.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const execall = require('execall');
|
|
1
|
+
import {promisify} from 'node:util';
|
|
2
|
+
import childProcess from 'node:child_process';
|
|
3
|
+
import execall from 'execall';
|
|
5
4
|
|
|
6
5
|
const TEN_MEBIBYTE = 1024 * 1024 * 10;
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export default async function killTabs() {
|
|
9
8
|
const command = 'wmic process where Caption=\'chrome.exe\' get CommandLine,ProcessId /format:list';
|
|
10
|
-
const stdout = await
|
|
9
|
+
const stdout = await promisify(childProcess.exec)(command, {maxBuffer: TEN_MEBIBYTE});
|
|
11
10
|
|
|
12
11
|
return execall(/CommandLine=(.+)\s+ProcessId=(\d+)/g, stdout).map(element => ({
|
|
13
|
-
cmd: element.
|
|
14
|
-
pid: parseInt(element.subMatches[1], 10)
|
|
12
|
+
cmd: element.subMatches[0],
|
|
13
|
+
pid: Number.parseInt(element.subMatches[1], 10),
|
|
15
14
|
}));
|
|
16
|
-
}
|
|
15
|
+
}
|