idea-manager 0.9.4 → 0.9.5
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/src/cli.ts +27 -15
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -22,32 +22,44 @@ try {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
async function openAsApp(url: string) {
|
|
25
|
-
const {
|
|
25
|
+
const { execFile: execFileCb } = await import('child_process');
|
|
26
|
+
const fs = await import('fs');
|
|
26
27
|
const platform = process.platform;
|
|
27
28
|
|
|
28
|
-
//
|
|
29
|
-
|
|
29
|
+
// Direct browser binary paths — avoids macOS `open -a --args` being ignored
|
|
30
|
+
// when browser is already running
|
|
31
|
+
const browsers: { bin: string; args: string[] }[] =
|
|
30
32
|
platform === 'darwin'
|
|
31
33
|
? [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
{ bin: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', args: [`--app=${url}`] },
|
|
35
|
+
{ bin: '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge', args: [`--app=${url}`] },
|
|
36
|
+
{ bin: '/Applications/Chromium.app/Contents/MacOS/Chromium', args: [`--app=${url}`] },
|
|
35
37
|
]
|
|
36
38
|
: platform === 'win32'
|
|
37
39
|
? [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
{ bin: 'chrome', args: [`--app=${url}`] },
|
|
41
|
+
{ bin: 'msedge', args: [`--app=${url}`] },
|
|
42
|
+
]
|
|
41
43
|
: [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
{ bin: 'google-chrome', args: [`--app=${url}`] },
|
|
45
|
+
{ bin: 'chromium-browser', args: [`--app=${url}`] },
|
|
46
|
+
{ bin: 'microsoft-edge', args: [`--app=${url}`] },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
for (const browser of browsers) {
|
|
50
|
+
// On macOS, check binary exists before trying
|
|
51
|
+
if (platform === 'darwin' && !fs.existsSync(browser.bin)) continue;
|
|
46
52
|
|
|
47
|
-
for (const cmd of commands) {
|
|
48
53
|
try {
|
|
49
54
|
await new Promise<void>((resolve, reject) => {
|
|
50
|
-
|
|
55
|
+
const child = execFileCb(browser.bin, browser.args, {
|
|
56
|
+
shell: platform === 'win32',
|
|
57
|
+
detached: true,
|
|
58
|
+
stdio: 'ignore',
|
|
59
|
+
}, (err) => { if (err) reject(err); });
|
|
60
|
+
child.unref();
|
|
61
|
+
// Browser launched — resolve after brief delay
|
|
62
|
+
setTimeout(resolve, 500);
|
|
51
63
|
});
|
|
52
64
|
return; // success
|
|
53
65
|
} catch {
|