@kisuke/cli 1.1.55-dev.64.1 → 1.1.57-dev.66.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/package.json +1 -1
- package/scripts/preuninstall.mjs +36 -3
package/package.json
CHANGED
package/scripts/preuninstall.mjs
CHANGED
|
@@ -27,9 +27,42 @@ const executable = process.platform === 'win32'
|
|
|
27
27
|
: path.join(bundleDir, 'kisuke');
|
|
28
28
|
|
|
29
29
|
if (fs.existsSync(executable)) {
|
|
30
|
-
spawnSync(executable, ['uninstall'], {
|
|
31
|
-
stdio: '
|
|
30
|
+
const result = spawnSync(executable, ['uninstall'], {
|
|
31
|
+
stdio: 'pipe',
|
|
32
32
|
shell: process.platform === 'win32',
|
|
33
|
-
timeout:
|
|
33
|
+
timeout: 30_000,
|
|
34
34
|
});
|
|
35
|
+
|
|
36
|
+
if (result.error) {
|
|
37
|
+
console.warn(`kisuke uninstall warning: ${result.error.message}`);
|
|
38
|
+
} else if (result.status !== 0) {
|
|
39
|
+
const stderr = result.stderr?.toString().trim();
|
|
40
|
+
if (stderr) {
|
|
41
|
+
console.warn(`kisuke uninstall warning: ${stderr}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// On Windows, if the daemon is still alive after service removal,
|
|
46
|
+
// kill it directly so npm can delete the bundled node.exe.
|
|
47
|
+
if (process.platform === 'win32') {
|
|
48
|
+
try {
|
|
49
|
+
const kisukeDir = path.join(process.env.USERPROFILE || '', '.kisuke');
|
|
50
|
+
const pidFile = path.join(kisukeDir, 'kisuke.pid');
|
|
51
|
+
const pid = parseInt(fs.readFileSync(pidFile, 'utf8').trim(), 10);
|
|
52
|
+
if (pid > 0) {
|
|
53
|
+
try {
|
|
54
|
+
process.kill(pid, 'SIGTERM');
|
|
55
|
+
} catch {
|
|
56
|
+
// Process may already be gone — try taskkill as last resort
|
|
57
|
+
spawnSync('taskkill', ['/F', '/PID', String(pid)], {
|
|
58
|
+
stdio: 'ignore',
|
|
59
|
+
timeout: 5_000,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
try { fs.unlinkSync(pidFile); } catch {}
|
|
63
|
+
}
|
|
64
|
+
} catch {
|
|
65
|
+
// No PID file or process already gone — fine
|
|
66
|
+
}
|
|
67
|
+
}
|
|
35
68
|
}
|