Killing Processes
Terminates the specified ports, port ranges and process IDs.
History
| Version | Changes |
|---|---|
| v2.5.0 | --kill-port in order to --killPort.--kill-range in order to --killRange.--kill-pid in order to --killPid. |
kill.portβ
kill.port(port: number | number[])
Terminates the specified ports.
- Requires
lsoffor Unix andnetstatfor Windows.
CLIβ
Terminates the specified ports before running the test suite.
npx poku --killPort="4000" targetPath
Also, terminating multiple ports:
npx poku --killPort="4000,4001" targetPath
Config Fileβ
- poku.config.js
- .pokurc.jsonc
import { defineConfig } from 'poku';
export default defineConfig({
kill: {
port: [4000],
},
});
{
"$schema": "https://poku.io/schemas/configs.json",
"kill": {
"port": [4000]
}
}
Helperβ
import { kill } from 'poku';
await kill.port(4000);
Also, terminating multiple ports:
await kill.port([4000, 4001]);
kill.rangeβ
kill.range(startsAt: number, endsAt: number)
Terminates the specified port range.
- Requires
lsoffor Unix andnetstatfor Windows.
CLIβ
Terminates the specified port range before running the test suite.
npx poku --killRange="4000-4100" targetPath
Also, terminating multiple port ranges:
npx poku --killRange="4000-4100,5000-5100" targetPath
Config Fileβ
- poku.config.js
- .pokurc.jsonc
import { defineConfig } from 'poku';
export default defineConfig({
kill: {
range: [[4000, 4100]],
},
});
{
"$schema": "https://poku.io/schemas/configs.json",
"kill": {
"range": [[4000, 4100]]
}
}
Helperβ
import { kill } from 'poku';
await kill.range(4000, 4100);
kill.pidβ
kill.pid(PID: number | number[])
Terminates the specified processes.
CLIβ
Terminates the specified processes before running the test suite
npx poku --killPid="100" targetPath
Also, terminating multiple processes:
npx poku --killPid="100,200" targetPath
Config Fileβ
- poku.config.js
- .pokurc.jsonc
import { defineConfig } from 'poku';
export default defineConfig({
kill: {
pid: [100],
},
});
{
"$schema": "https://poku.io/schemas/configs.json",
"kill": {
"pid": [100]
}
}
Helperβ
import { kill } from 'poku';
await kill.pid(100);
Also, terminating multiple processes:
await kill.pid([100, 200]);
If your environment doesn't include lsof by default:
macOS (Homebrew)
brew install lsof
Debian, Ubuntu, etc.
sudo apt-get install lsof
Arch Linux, etc.
sudo pacman -S lsof
Alpine Linux, etc.
apk add lsof