send-to-pi 1.0.2 → 1.2.0

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.
@@ -2,35 +2,56 @@
2
2
  * Windows Terminal Launcher for send-to-pi
3
3
  *
4
4
  * Supports:
5
- * - Windows Terminal (wt.exe)
5
+ * - Tern Terminal (D:\Tern\tern.exe)
6
+ * - Windows Terminal (wt.exe fallback)
6
7
  * - PowerShell (powershell.exe fallback)
7
8
  * - Command Prompt (cmd.exe fallback)
8
9
  */
9
10
 
10
11
  const { spawn } = require('child_process');
12
+ const fs = require('fs');
11
13
 
12
14
  function launchWin32(workDir) {
13
15
  return new Promise((resolve) => {
14
- // 1. 尝试 Windows Terminal (wt.exe)
15
- try {
16
- const wtArgs = ['-d', workDir, 'powershell', '-NoExit', '-Command', 'pi'];
17
- const child = spawn('wt.exe', wtArgs, {
18
- detached: true,
19
- stdio: 'ignore',
20
- });
16
+ // 1. 优先尝试 Tern Terminal (主力终端)
17
+ const ternPath = 'D:\\Tern\\tern.exe';
18
+ if (fs.existsSync(ternPath)) {
19
+ try {
20
+ const ternArgs = ['-e', 'powershell', '-NoExit', '-Command', `Set-Location '${workDir}'; pi`];
21
+ const child = spawn(ternPath, ternArgs, {
22
+ detached: true,
23
+ stdio: 'ignore',
24
+ });
25
+ child.on('error', () => fallbackWT(workDir, resolve));
26
+ child.unref();
27
+ setTimeout(() => resolve({ success: true, terminal: 'Tern' }), 300);
28
+ return;
29
+ } catch (_e) {
30
+ // continue
31
+ }
32
+ }
33
+ fallbackWT(workDir, resolve);
34
+ });
35
+ }
21
36
 
22
- child.on('error', (_err) => {
23
- // wt.exe 不存在或失败,回退到 powershell.exe
24
- fallbackPowerShell(workDir, resolve);
25
- });
37
+ function fallbackWT(workDir, resolve) {
38
+ // 2. 回退尝试 Windows Terminal (wt.exe)
39
+ try {
40
+ const wtArgs = ['-d', workDir, 'powershell', '-NoExit', '-Command', 'pi'];
41
+ const child = spawn('wt.exe', wtArgs, {
42
+ detached: true,
43
+ stdio: 'ignore',
44
+ });
26
45
 
27
- child.unref();
28
- // 在 Windows 上若成功触发 spawn 且无即时报错即视为已拉起
29
- setTimeout(() => resolve({ success: true, terminal: 'Windows Terminal' }), 300);
30
- } catch (_e) {
46
+ child.on('error', (_err) => {
31
47
  fallbackPowerShell(workDir, resolve);
32
- }
33
- });
48
+ });
49
+
50
+ child.unref();
51
+ setTimeout(() => resolve({ success: true, terminal: 'Windows Terminal' }), 300);
52
+ } catch (_e) {
53
+ fallbackPowerShell(workDir, resolve);
54
+ }
34
55
  }
35
56
 
36
57
  function fallbackPowerShell(workDir, resolve) {