hungry-ghost-hive 0.40.2 → 0.40.3
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/README.md
CHANGED
|
@@ -705,6 +705,8 @@ We appreciate contributions from everyone! This project is built and maintained
|
|
|
705
705
|
<tr>
|
|
706
706
|
<td align="center"><a href="https://github.com/nikrich"><img src="https://avatars.githubusercontent.com/u/8254123?v=4?s=100" width="100px;" alt=""/><br /><sub><b>nikrich</b></sub></a><br /><a href="https://github.com/nikrich/hungry-ghost-hive/commits?author=nikrich" title="Code">💻</a> <a href="https://github.com/nikrich/hungry-ghost-hive/commits?author=nikrich" title="Documentation">📖</a> <a href="#infra-nikrich" title="Infrastructure">🚀</a> <a href="#maintenance-nikrich" title="Maintenance">🚧</a></td>
|
|
707
707
|
<td align="center"><a href="https://github.com/aleeuwen73"><img src="https://avatars.githubusercontent.com/u/73424841?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alastair van Leeuwen</b></sub></a><br /><a href="https://github.com/nikrich/hungry-ghost-hive/commits?author=aleeuwen73" title="Code">💻</a></td>
|
|
708
|
+
<td align="center"><a href="https://github.com/tzone85"><img src="https://avatars.githubusercontent.com/u/6205552?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Thando Mini</b></sub></a><br /><a href="https://github.com/nikrich/hungry-ghost-hive/commits?author=tzone85" title="Code">💻</a> <a href="https://github.com/nikrich/hungry-ghost-hive/commits?author=tzone85" title="Security">🛡️</a></td>
|
|
709
|
+
<td align="center"><a href="https://github.com/verigateart"><img src="https://avatars.githubusercontent.com/u/219031990?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Arthur</b></sub></a><br /><a href="https://github.com/nikrich/hungry-ghost-hive/commits?author=verigateart" title="Code">💻</a></td>
|
|
708
710
|
</tr>
|
|
709
711
|
</table>
|
|
710
712
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Open a URL in the user's default browser
|
|
2
|
+
* Open a URL in the user's default browser, or a specific browser if the
|
|
3
|
+
* BROWSER environment variable is set (e.g. BROWSER="Google Chrome" on macOS).
|
|
3
4
|
* Falls back silently if the browser cannot be opened.
|
|
4
5
|
*/
|
|
5
6
|
export declare function openBrowser(url: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-browser.d.ts","sourceRoot":"","sources":["../../src/utils/open-browser.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"open-browser.d.ts","sourceRoot":"","sources":["../../src/utils/open-browser.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B5D"}
|
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
// Licensed under the Hungry Ghost Hive License. See LICENSE.
|
|
2
|
-
import {
|
|
2
|
+
import { execFile } from 'child_process';
|
|
3
3
|
/**
|
|
4
|
-
* Open a URL in the user's default browser
|
|
4
|
+
* Open a URL in the user's default browser, or a specific browser if the
|
|
5
|
+
* BROWSER environment variable is set (e.g. BROWSER="Google Chrome" on macOS).
|
|
5
6
|
* Falls back silently if the browser cannot be opened.
|
|
6
7
|
*/
|
|
7
8
|
export async function openBrowser(url) {
|
|
8
|
-
const
|
|
9
|
+
const browserEnv = process.env.BROWSER;
|
|
10
|
+
let bin;
|
|
11
|
+
let args;
|
|
12
|
+
if (process.platform === 'darwin') {
|
|
13
|
+
if (browserEnv) {
|
|
14
|
+
bin = 'open';
|
|
15
|
+
args = ['-a', browserEnv, url];
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
bin = 'open';
|
|
19
|
+
args = [url];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else if (process.platform === 'win32') {
|
|
23
|
+
bin = 'cmd';
|
|
24
|
+
args = browserEnv ? ['/c', 'start', '', browserEnv, url] : ['/c', 'start', '', url];
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
bin = browserEnv ?? 'xdg-open';
|
|
28
|
+
args = [url];
|
|
29
|
+
}
|
|
9
30
|
return new Promise(resolve => {
|
|
10
|
-
|
|
31
|
+
execFile(bin, args, err => {
|
|
11
32
|
if (err) {
|
|
12
|
-
// Don't throw - caller should print the URL as fallback
|
|
13
33
|
console.warn(`Could not open browser automatically. Please open the URL manually.`);
|
|
14
34
|
}
|
|
15
35
|
resolve();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-browser.js","sourceRoot":"","sources":["../../src/utils/open-browser.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"open-browser.js","sourceRoot":"","sources":["../../src/utils/open-browser.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW;IAC3C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IAEvC,IAAI,GAAW,CAAC;IAChB,IAAI,IAAc,CAAC;IAEnB,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClC,IAAI,UAAU,EAAE,CAAC;YACf,GAAG,GAAG,MAAM,CAAC;YACb,IAAI,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,GAAG,GAAG,MAAM,CAAC;YACb,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC;SAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACxC,GAAG,GAAG,KAAK,CAAC;QACZ,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IACtF,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,UAAU,IAAI,UAAU,CAAC;QAC/B,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAED,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE;YACxB,IAAI,GAAG,EAAE,CAAC;gBACR,OAAO,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;YACtF,CAAC;YACD,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
// Licensed under the Hungry Ghost Hive License. See LICENSE.
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { execFile } from 'child_process';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Open a URL in the user's default browser
|
|
6
|
+
* Open a URL in the user's default browser, or a specific browser if the
|
|
7
|
+
* BROWSER environment variable is set (e.g. BROWSER="Google Chrome" on macOS).
|
|
7
8
|
* Falls back silently if the browser cannot be opened.
|
|
8
9
|
*/
|
|
9
10
|
export async function openBrowser(url: string): Promise<void> {
|
|
10
|
-
const
|
|
11
|
-
|
|
11
|
+
const browserEnv = process.env.BROWSER;
|
|
12
|
+
|
|
13
|
+
let bin: string;
|
|
14
|
+
let args: string[];
|
|
15
|
+
|
|
16
|
+
if (process.platform === 'darwin') {
|
|
17
|
+
if (browserEnv) {
|
|
18
|
+
bin = 'open';
|
|
19
|
+
args = ['-a', browserEnv, url];
|
|
20
|
+
} else {
|
|
21
|
+
bin = 'open';
|
|
22
|
+
args = [url];
|
|
23
|
+
}
|
|
24
|
+
} else if (process.platform === 'win32') {
|
|
25
|
+
bin = 'cmd';
|
|
26
|
+
args = browserEnv ? ['/c', 'start', '', browserEnv, url] : ['/c', 'start', '', url];
|
|
27
|
+
} else {
|
|
28
|
+
bin = browserEnv ?? 'xdg-open';
|
|
29
|
+
args = [url];
|
|
30
|
+
}
|
|
12
31
|
|
|
13
32
|
return new Promise(resolve => {
|
|
14
|
-
|
|
33
|
+
execFile(bin, args, err => {
|
|
15
34
|
if (err) {
|
|
16
|
-
// Don't throw - caller should print the URL as fallback
|
|
17
35
|
console.warn(`Could not open browser automatically. Please open the URL manually.`);
|
|
18
36
|
}
|
|
19
37
|
resolve();
|