channel-worker 1.3.8 → 1.3.9
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/lib/updater.js +10 -2
- package/package.json +1 -1
package/lib/updater.js
CHANGED
|
@@ -44,12 +44,20 @@ async function checkAndUpdate({ autoRestart = false } = {}) {
|
|
|
44
44
|
|
|
45
45
|
if (autoRestart) {
|
|
46
46
|
console.log('[updater] Restarting daemon...');
|
|
47
|
-
// Spawn detached process with same args, then exit current
|
|
48
47
|
const { spawn } = require('child_process');
|
|
49
|
-
const
|
|
48
|
+
const isWindows = process.platform === 'win32';
|
|
49
|
+
|
|
50
|
+
// Use the global binary name instead of process.argv to pick up new version
|
|
51
|
+
const cmd = isWindows ? 'cmd' : 'sh';
|
|
52
|
+
const args = isWindows
|
|
53
|
+
? ['/c', 'timeout /t 2 /nobreak >nul && channel-worker start']
|
|
54
|
+
: ['-c', 'sleep 2 && channel-worker start'];
|
|
55
|
+
|
|
56
|
+
const child = spawn(cmd, args, {
|
|
50
57
|
detached: true,
|
|
51
58
|
stdio: 'ignore',
|
|
52
59
|
cwd: process.cwd(),
|
|
60
|
+
shell: false,
|
|
53
61
|
});
|
|
54
62
|
child.unref();
|
|
55
63
|
process.exit(0);
|