hirify-cli 0.4.6 → 0.4.7
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/bin/hirify.js +2 -5
- package/bin/open-browser.js +13 -0
- package/package.json +1 -1
package/bin/hirify.js
CHANGED
|
@@ -17,6 +17,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
17
17
|
import { createServer } from 'node:http'
|
|
18
18
|
import { execFileSync, spawn, spawnSync } from 'node:child_process'
|
|
19
19
|
import { randomBytes, createHash } from 'node:crypto'
|
|
20
|
+
import { browserCandidates } from './open-browser.js'
|
|
20
21
|
|
|
21
22
|
const API = process.env.HIRIFY_API || 'https://api.hirify.me'
|
|
22
23
|
// The two public well-known documents the CLI is allowed to hardcode. OAuth discovery is
|
|
@@ -816,11 +817,7 @@ function browserPage(error) {
|
|
|
816
817
|
* appeared is not something we can know, so the link is printed either way.
|
|
817
818
|
*/
|
|
818
819
|
function openBrowser(url) {
|
|
819
|
-
const candidates =
|
|
820
|
-
? [[process.env.BROWSER, [url]]]
|
|
821
|
-
: process.platform === 'darwin' ? [['open', [url]]]
|
|
822
|
-
: process.platform === 'win32' ? [['cmd', ['/c', 'start', '', url]]]
|
|
823
|
-
: [['xdg-open', [url]], ['gio', ['open', url]], ['sensible-browser', [url]], ['x-www-browser', [url]]]
|
|
820
|
+
const candidates = browserCandidates(url)
|
|
824
821
|
|
|
825
822
|
const tryOne = (i) => new Promise((resolve) => {
|
|
826
823
|
if (i >= candidates.length) return resolve(false)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands that ask the operating system to open a URL in the default browser.
|
|
3
|
+
*
|
|
4
|
+
* Windows must not receive the URL through cmd.exe: `&` is command syntax there, so an
|
|
5
|
+
* OAuth URL would be cut off after its first query parameter. Explorer receives the URL
|
|
6
|
+
* as one process argument and leaves every parameter intact.
|
|
7
|
+
*/
|
|
8
|
+
export function browserCandidates(url, platform = process.platform, browser = process.env.BROWSER) {
|
|
9
|
+
if (browser) return [[browser, [url]]]
|
|
10
|
+
if (platform === 'darwin') return [['open', [url]]]
|
|
11
|
+
if (platform === 'win32') return [['explorer.exe', [url]]]
|
|
12
|
+
return [['xdg-open', [url]], ['gio', ['open', url]], ['sensible-browser', [url]], ['x-www-browser', [url]]]
|
|
13
|
+
}
|
package/package.json
CHANGED