@quangnv13/nonstop 1.0.11 → 1.0.12
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/package.json +4 -2
- package/scripts/preinstall.js +35 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quangnv13/nonstop",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"preferGlobal": true,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"dist",
|
|
31
31
|
"images",
|
|
32
|
+
"scripts",
|
|
32
33
|
"README.md",
|
|
33
34
|
"README.vi.md"
|
|
34
35
|
],
|
|
@@ -39,7 +40,8 @@
|
|
|
39
40
|
"dev": "tsx watch src/index.ts",
|
|
40
41
|
"build": "tsc -p tsconfig.json",
|
|
41
42
|
"start": "node dist/index.js",
|
|
42
|
-
"test": "node --import tsx --test src/*.test.ts"
|
|
43
|
+
"test": "node --import tsx --test src/*.test.ts",
|
|
44
|
+
"preinstall": "node scripts/preinstall.js"
|
|
43
45
|
},
|
|
44
46
|
"dependencies": {
|
|
45
47
|
"boxen": "^5.1.2",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execSync } = require('child_process');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
|
|
5
|
+
function killOldProcesses() {
|
|
6
|
+
const platform = os.platform();
|
|
7
|
+
console.log(`[nonstop] Pre-install hook: Checking for running nonstop processes on ${platform}...`);
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
if (platform === 'win32') {
|
|
11
|
+
// Windows PowerShell command to find and kill node processes running nonstop background
|
|
12
|
+
const cmd = `powershell -NoProfile -Command "Get-CimInstance Win32_Process -Filter \\"name = 'node.exe'\\" | Where-Object { $_.CommandLine -like '*nonstop*' -and $_.CommandLine -like '*--background*' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force; Write-Host 'Killed nonstop background process PID' $_.ProcessId }"`;
|
|
13
|
+
const output = execSync(cmd, { encoding: 'utf8' });
|
|
14
|
+
if (output.trim()) {
|
|
15
|
+
console.log(output.trim());
|
|
16
|
+
} else {
|
|
17
|
+
console.log('[nonstop] No running nonstop background processes found on Windows.');
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
// Unix/Linux/macOS command
|
|
21
|
+
try {
|
|
22
|
+
const cmd = `pkill -9 -f "node.*nonstop.*--background"`;
|
|
23
|
+
execSync(cmd);
|
|
24
|
+
console.log('[nonstop] Killed running nonstop background processes on Unix.');
|
|
25
|
+
} catch (err) {
|
|
26
|
+
// pkill exits with 1 if no processes match
|
|
27
|
+
console.log('[nonstop] No running nonstop background processes found on Unix.');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.warn('[nonstop] Warning during pre-install check:', error.message);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
killOldProcesses();
|