Skip to content

Commit 6c21ca2

Browse files
committed
vscode-close-process
1 parent 39a938d commit 6c21ca2

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { execSync } from 'child_process'
2+
3+
export class VScodeScripts {
4+
/**
5+
* Function to terminate specific Node processes
6+
* @param path - The path of node process
7+
*/
8+
static terminateSpecificNodeProcesses(path: string) {
9+
try {
10+
// Find PIDs of Node processes matching the specific pattern
11+
const pids = execSync(`pgrep -f "node ${path}"`)
12+
.toString()
13+
.trim()
14+
.split('\n')
15+
16+
if (pids.length > 0) {
17+
// Terminate processes with the found PIDs
18+
pids.forEach(pid => {
19+
execSync(`kill ${pid}`)
20+
})
21+
} else {
22+
console.log('No matching processes found.')
23+
}
24+
} catch (error: any) {
25+
console.error(
26+
`Error terminating specific Node processes: ${error.message}`,
27+
)
28+
}
29+
}
30+
}

tests/e2e/src/vscode.runner.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { logging } from 'selenium-webdriver'
77
import * as fs from 'fs'
88
import path = require('path')
99
import { Config } from './helpers/Conf'
10-
10+
import { VScodeScripts } from './helpers/scripts/vscodeScripts'
1111
;(async (): Promise<void> => {
1212
try {
1313
// Delete mochawesome-report directory
@@ -27,13 +27,31 @@ import { Config } from './helpers/Conf'
2727
'test-extensions',
2828
`redis ltd..${Config.extensionName.replace('.vsix', '')}`,
2929
)
30+
const extensionProcessPath = path.join(
31+
__dirname,
32+
'..',
33+
'test-extensions',
34+
'redis.redis-insight-vsc-plugin-0.0.1',
35+
'dist',
36+
'redis-backend',
37+
'dist',
38+
'src',
39+
'main.js',
40+
)
3041
// Install VSCode and Chromedriver
3142
await exTester.downloadCode()
3243
await exTester.downloadChromeDriver()
3344
// Install vsix if not installed yet
3445
if (!fs.existsSync(extensionDir)) {
3546
await exTester.installVsix({
36-
vsixFile: path.join(__dirname, '..', '..', '..', 'release', Config.extensionName),
47+
vsixFile: path.join(
48+
__dirname,
49+
'..',
50+
'..',
51+
'..',
52+
'release',
53+
Config.extensionName,
54+
),
3755
useYarn: true,
3856
installDependencies: true,
3957
})
@@ -52,6 +70,8 @@ import { Config } from './helpers/Conf'
5270
resources: [],
5371
},
5472
)
73+
// Terminate extension node process
74+
VScodeScripts.terminateSpecificNodeProcesses(extensionProcessPath)
5575
} catch (error) {
5676
console.error(error)
5777
process.exit(1)

0 commit comments

Comments
 (0)