@vltpkg/url-open 0.0.0-9 → 1.0.0-rc.1
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/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +17 -5
- package/dist/esm/index.js.map +1 -1
- package/package.json +11 -9
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type OpenOptions = {
|
|
2
2
|
signal?: AbortSignal;
|
|
3
3
|
};
|
|
4
|
-
export declare const urlOpen: (url: string, { signal }?: OpenOptions) => Promise<Omit<import("@vltpkg/promise-spawn").SpawnResult, "stdout" | "stderr"> & {
|
|
4
|
+
export declare const urlOpen: (url: string, { signal }?: OpenOptions) => Promise<(Omit<import("@vltpkg/promise-spawn").SpawnResult, "stdout" | "stderr"> & {
|
|
5
5
|
stdout: null;
|
|
6
6
|
stderr: null;
|
|
7
|
-
} & object>;
|
|
7
|
+
} & object) | undefined>;
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,CAAA;AAKD,eAAO,MAAM,OAAO,QACb,MAAM,eACC,WAAW;;;wBAsCxB,CAAA"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
import { promiseSpawn } from '@vltpkg/promise-spawn';
|
|
2
|
+
import { which } from '@vltpkg/which';
|
|
2
3
|
import { release } from 'node:os';
|
|
3
4
|
let { platform } = process;
|
|
4
5
|
if (platform === 'linux' &&
|
|
5
6
|
release().toLowerCase().includes('microsoft')) {
|
|
6
7
|
platform = 'win32';
|
|
7
8
|
}
|
|
9
|
+
// eslint-disable-next-line no-console
|
|
10
|
+
const log = (msg) => console.error(msg);
|
|
8
11
|
export const urlOpen = async (url, { signal } = {}) => {
|
|
9
|
-
const cmd = platform === 'win32' ? 'start
|
|
12
|
+
const cmd = platform === 'win32' ? 'start'
|
|
10
13
|
: platform === 'darwin' ? 'open'
|
|
11
14
|
: 'xdg-open';
|
|
12
|
-
const args =
|
|
15
|
+
const args = [url];
|
|
13
16
|
// print as hyperlink if we think it's a TTY
|
|
14
17
|
// TODO: only do if chalk says the support level is high enough
|
|
15
18
|
const link = process.stderr.isTTY ?
|
|
16
19
|
`\u001b]8;;${url}\u001b\\${url}\u001b]8;;\u001b\\`
|
|
17
20
|
: url;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
if (
|
|
22
|
+
// Use stdin.isTTY to detect if we should attempt to open
|
|
23
|
+
// a browser or not
|
|
24
|
+
!process.stdin.isTTY ||
|
|
25
|
+
// Also check if the command is available since we don't
|
|
26
|
+
// want the process to exit if we aren't able to open a browser.
|
|
27
|
+
(await which(cmd, { nothrow: true })) === null) {
|
|
28
|
+
log(`Could not open a browser. Please open ${link} manually.`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
log(`Opening a web browser to: ${link}`);
|
|
32
|
+
return promiseSpawn(platform === 'win32' ? `${cmd} ""` : cmd, platform === 'win32' ? ['""', ...args] : args, {
|
|
21
33
|
signal,
|
|
22
34
|
shell: true,
|
|
23
35
|
stdio: 'inherit',
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,IAAI,EAAE,QAAQ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AO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpB,aAAa,GAAG,WAAW,GAAG,oBAAoB;QACpD,CAAC,CAAC,GAAG,CAAA;IAEP;IACE,yDAAyD;IACzD,mBAAmB;IACnB,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK;QACpB,wDAAwD;QACxD,gEAAgE;QAChE,CAAC,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,IAAI,EAC9C,CAAC;QACD,GAAG,CAAC,yCAAyC,IAAI,YAAY,CAAC,CAAA;QAC9D,OAAM;IACR,CAAC;IAED,GAAG,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAA;IAExC,OAAO,YAAY,CACjB,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,EACxC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAC7C;QACE,MAAM;QACN,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,SAAS;KACjB,CACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { promiseSpawn } from '@vltpkg/promise-spawn'\nimport { which } from '@vltpkg/which'\nimport { release } from 'node:os'\n\nlet { platform } = process\nif (\n platform === 'linux' &&\n release().toLowerCase().includes('microsoft')\n) {\n platform = 'win32'\n}\n\nexport type OpenOptions = {\n signal?: AbortSignal\n}\n\n// eslint-disable-next-line no-console\nconst log = (msg: string) => console.error(msg)\n\nexport const urlOpen = async (\n url: string,\n { signal }: OpenOptions = {},\n) => {\n const cmd =\n platform === 'win32' ? 'start'\n : platform === 'darwin' ? 'open'\n : 'xdg-open'\n const args = [url]\n\n // print as hyperlink if we think it's a TTY\n // TODO: only do if chalk says the support level is high enough\n const link =\n process.stderr.isTTY ?\n `\\u001b]8;;${url}\\u001b\\\\${url}\\u001b]8;;\\u001b\\\\`\n : url\n\n if (\n // Use stdin.isTTY to detect if we should attempt to open\n // a browser or not\n !process.stdin.isTTY ||\n // Also check if the command is available since we don't\n // want the process to exit if we aren't able to open a browser.\n (await which(cmd, { nothrow: true })) === null\n ) {\n log(`Could not open a browser. Please open ${link} manually.`)\n return\n }\n\n log(`Opening a web browser to: ${link}`)\n\n return promiseSpawn(\n platform === 'win32' ? `${cmd} \"\"` : cmd,\n platform === 'win32' ? ['\"\"', ...args] : args,\n {\n signal,\n shell: true,\n stdio: 'inherit',\n },\n )\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/url-open",
|
|
3
3
|
"description": "Open URLs using the system's default web browser",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.0.0-rc.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
8
8
|
"directory": "src/url-open"
|
|
9
9
|
},
|
|
10
|
+
"author": "vlt technology inc. <support@vlt.sh> (http://vlt.sh)",
|
|
10
11
|
"tshy": {
|
|
11
12
|
"selfLink": false,
|
|
12
13
|
"liveDev": true,
|
|
@@ -19,19 +20,19 @@
|
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@vltpkg/promise-spawn": "
|
|
23
|
+
"@vltpkg/promise-spawn": "1.0.0-rc.1",
|
|
24
|
+
"@vltpkg/which": "1.0.0-rc.1"
|
|
23
25
|
},
|
|
24
26
|
"devDependencies": {
|
|
25
|
-
"@eslint/js": "^9.
|
|
26
|
-
"@types/
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"prettier": "^3.4.2",
|
|
27
|
+
"@eslint/js": "^9.34.0",
|
|
28
|
+
"@types/node": "^22.17.2",
|
|
29
|
+
"eslint": "^9.34.0",
|
|
30
|
+
"prettier": "^3.6.2",
|
|
30
31
|
"tap": "^21.1.0",
|
|
31
32
|
"tshy": "^3.0.2",
|
|
32
|
-
"typedoc": "0.27.
|
|
33
|
+
"typedoc": "~0.27.9",
|
|
33
34
|
"typescript": "5.7.3",
|
|
34
|
-
"typescript-eslint": "^8.
|
|
35
|
+
"typescript-eslint": "^8.40.0"
|
|
35
36
|
},
|
|
36
37
|
"license": "BSD-2-Clause-Patent",
|
|
37
38
|
"engines": {
|
|
@@ -63,6 +64,7 @@
|
|
|
63
64
|
"snap": "tap",
|
|
64
65
|
"test": "tap",
|
|
65
66
|
"posttest": "tsc --noEmit",
|
|
67
|
+
"tshy": "tshy",
|
|
66
68
|
"typecheck": "tsc --noEmit"
|
|
67
69
|
}
|
|
68
70
|
}
|