kill-tabs 3.1.1 → 4.1.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 CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';
3
- const meow = require('meow');
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
@@ -11,21 +10,27 @@ const cli = meow(`
11
10
  --no-chromium Don't kill tabs in Chromium
12
11
  --no-chrome Don't kill tabs in Chrome
13
12
  --no-brave Don't kill tabs in Brave
13
+ --no-edge Don't kill tabs in Edge
14
14
  `, {
15
+ importMeta: import.meta,
15
16
  flags: {
16
17
  chromium: {
17
18
  type: 'boolean',
18
- default: true
19
+ default: true,
19
20
  },
20
21
  chrome: {
21
22
  type: 'boolean',
22
- default: true
23
+ default: true,
23
24
  },
24
25
  brave: {
25
26
  type: 'boolean',
26
- default: true
27
- }
28
- }
27
+ default: true,
28
+ },
29
+ edge: {
30
+ type: 'boolean',
31
+ default: true,
32
+ },
33
+ },
29
34
  });
30
35
 
31
36
  killTabs(cli.flags);
package/index.js CHANGED
@@ -1,18 +1,17 @@
1
- 'use strict';
2
- const fkill = require('fkill');
3
- let psList = require('ps-list');
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
- if (process.platform === 'win32') {
6
- psList = require('./windows');
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',
14
+ edge: process.platform === 'darwin' ? 'Microsoft Edge Helper' : 'edge',
16
15
  };
17
16
 
18
17
  if (options.chromium === false) {
@@ -27,13 +26,17 @@ module.exports = async (options = {}) => {
27
26
  delete processes.brave;
28
27
  }
29
28
 
29
+ if (options.edge === false) {
30
+ delete processes.edge;
31
+ }
32
+
30
33
  const pids = list
31
- .filter(x =>
32
- Object.keys(processes).some(name => x.cmd.includes(processes[name])) &&
33
- x.cmd.includes('--type=renderer') &&
34
- !x.cmd.includes('--extension-process')
34
+ .filter(process_ =>
35
+ Object.keys(processes).some(name => process_.cmd.includes(processes[name]))
36
+ && process_.cmd.includes('--type=renderer')
37
+ && !process_.cmd.includes('--extension-process'),
35
38
  )
36
- .map(x => x.pid);
39
+ .map(process_ => process_.pid);
37
40
 
38
41
  return fkill(pids, {force: true});
39
- };
42
+ }
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.1.1",
3
+ "version": "4.1.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",
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
- "bin": "cli.js",
13
+ "type": "module",
14
+ "bin": "./cli.js",
15
+ "exports": "./index.js",
13
16
  "engines": {
14
- "node": ">=8"
17
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
15
18
  },
16
19
  "scripts": {
17
20
  "test": "xo && ava"
@@ -26,6 +29,7 @@
26
29
  "cli",
27
30
  "chrome",
28
31
  "brave",
32
+ "edge",
29
33
  "browser",
30
34
  "tabs",
31
35
  "kill",
@@ -33,14 +37,13 @@
33
37
  "performance"
34
38
  ],
35
39
  "dependencies": {
36
- "execall": "^2.0.0",
37
- "fkill": "^6.2.0",
38
- "meow": "^5.0.0",
39
- "pify": "^4.0.1",
40
- "ps-list": "^6.3.0"
40
+ "execall": "^3.0.0",
41
+ "fkill": "^8.0.0",
42
+ "meow": "^10.1.1",
43
+ "ps-list": "^7.2.0"
41
44
  },
42
45
  "devDependencies": {
43
- "ava": "^2.4.0",
44
- "xo": "^0.25.3"
46
+ "ava": "^3.15.0",
47
+ "xo": "^0.45.0"
45
48
  }
46
49
  }
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- # kill-tabs [![Build Status](https://travis-ci.org/sindresorhus/kill-tabs.svg?branch=master)](https://travis-ci.org/sindresorhus/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
- $ npm install --global kill-tabs
15
+ ```sh
16
+ npm install --global kill-tabs
18
17
  ```
19
18
 
20
19
  ```
@@ -27,25 +26,22 @@ $ kill-tabs --help
27
26
  --no-chromium Don't kill tabs in Chromium
28
27
  --no-chrome Don't kill tabs in Chrome
29
28
  --no-brave Don't kill tabs in Brave
29
+ --no-edge Don't kill tabs in Edge
30
30
  ```
31
31
 
32
-
33
32
  ## API
34
33
 
35
- ```
36
- $ npm install kill-tabs
34
+ ```sh
35
+ npm install kill-tabs
37
36
  ```
38
37
 
39
38
  ```js
40
- const killTabs = require('kill-tabs');
39
+ import killTabs from 'kill-tabs';
41
40
 
42
- (async () => {
43
- await killTabs();
44
- console.log('Killed tabs');
45
- })();
41
+ await killTabs();
42
+ console.log('Killed tabs');
46
43
  ```
47
44
 
48
-
49
45
  ## Tip
50
46
 
51
47
  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
- 'use strict';
2
- const childProcess = require('child_process');
3
- const pify = require('pify');
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
- module.exports = async () => {
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 pify(childProcess.exec)(command, {maxBuffer: TEN_MEBIBYTE});
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
12
  cmd: element.subMatches[0],
14
- pid: parseInt(element.subMatches[1], 10)
13
+ pid: Number.parseInt(element.subMatches[1], 10),
15
14
  }));
16
- };
15
+ }