@vitest-preview/dev-utils
Advanced tools
| import { execSync } from 'child_process'; | ||
| import path from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import open from 'open'; | ||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| var OSX_CHROME = "google chrome"; | ||
| function openBrowser(url) { | ||
| let browser = process.env.BROWSER; | ||
| if (browser === "none") { | ||
| return false; | ||
| } | ||
| const shouldTryOpenChromeWithAppleScript = process.platform === "darwin" && (typeof browser !== "string" || browser === OSX_CHROME); | ||
| if (shouldTryOpenChromeWithAppleScript) { | ||
| const supportedChromiumBrowsers = [ | ||
| "Google Chrome Canary", | ||
| "Google Chrome Dev", | ||
| "Google Chrome Beta", | ||
| "Google Chrome", | ||
| "Microsoft Edge", | ||
| "Brave Browser", | ||
| "Vivaldi", | ||
| "Chromium" | ||
| ]; | ||
| for (let chromiumBrowser of supportedChromiumBrowsers) { | ||
| try { | ||
| execSync(`ps cax | grep "${chromiumBrowser}"`); | ||
| execSync( | ||
| `osascript openChrome.applescript "${encodeURI( | ||
| url | ||
| )}" "${chromiumBrowser}"`, | ||
| { | ||
| cwd: __dirname, | ||
| stdio: "ignore" | ||
| } | ||
| ); | ||
| return true; | ||
| } catch (err) { | ||
| } | ||
| } | ||
| } | ||
| if (process.platform === "darwin" && browser === "open") { | ||
| browser = void 0; | ||
| } | ||
| try { | ||
| var options = { app: browser }; | ||
| open(url, options).catch(() => { | ||
| }); | ||
| return true; | ||
| } catch (err) { | ||
| return false; | ||
| } | ||
| } | ||
| var index = { | ||
| openBrowser | ||
| }; | ||
| export { index as default, openBrowser }; |
+21
| MIT License | ||
| Copyright (c) 2022 Hung Viet Nguyen | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
+7
-11
| { | ||
| "name": "@vitest-preview/dev-utils", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2-alpha.0", | ||
| "description": "", | ||
| "type": "module", | ||
| "main": "dist/index.js", | ||
| "module": "dist/index.js", | ||
| "module": "dist/index.mjs", | ||
| "types": "dist/index.d.ts", | ||
@@ -19,17 +19,13 @@ "files": [ | ||
| "devDependencies": { | ||
| "@rollup/plugin-commonjs": "^23.0.2", | ||
| "@rollup/plugin-json": "^5.0.1", | ||
| "@rollup/plugin-node-resolve": "^15.0.1", | ||
| "rollup": "^3.2.3", | ||
| "rollup-plugin-dts": "^5.0.0", | ||
| "rollup-plugin-esbuild": "^4.10.1" | ||
| "@types/node": "^20.14.6", | ||
| "pkgroll": "2.1.1" | ||
| }, | ||
| "dependencies": { | ||
| "open": "^8.4.0" | ||
| "open": "^10.1.0" | ||
| }, | ||
| "scripts": { | ||
| "copy": "mkdir dist && cp src/openChrome.applescript dist/openChrome.applescript", | ||
| "build": "rimraf dist && pnpm run copy && rollup -c", | ||
| "build:watch": "rimraf dist && pnpm run copy && rollup -c -w" | ||
| "build": "rimraf dist && pnpm run copy && pkgroll", | ||
| "build:watch": "rimraf dist && pnpm run copy && pkgroll --watch" | ||
| } | ||
| } |
7716
44.96%2
-66.67%6
50%117
91.8%3
50%2
100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
Updated