Skip to content

Commit

Permalink
chore:switch open to opener
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Mar 20, 2024
1 parent ef913f0 commit 0002dd7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 193 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@geist-ui/icons": "^1.0.2",
"@stylexjs/stylex": "^0.5.1",
"@types/node": "^20.7.0",
"@types/opener": "^1.4.3",
"@types/react": "^18.2.31",
"@types/react-dom": "18.2.7",
"@vitejs/plugin-react": "^4.2.1",
Expand Down Expand Up @@ -112,7 +113,7 @@
"esbuild-minify-templates@^0.11.0": "patch:esbuild-minify-templates@npm%3A0.11.0#./.yarn/patches/esbuild-minify-templates-npm-0.11.0-458ab522a4.patch"
},
"dependencies": {
"open": "^9.1.0",
"opener": "^1.5.2",
"picocolors": "^1.0.0",
"source-map": "^0.7.4"
},
Expand Down
7 changes: 4 additions & 3 deletions src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path'
import fsp from 'fs/promises'
import opener from 'opener'
import type { Logger, Plugin } from 'vite'
import colors from 'picocolors'
import { name } from '../../package.json'
Expand All @@ -12,8 +13,8 @@ import { convertBytes } from './shared'

const isCI = !!process.env.CI

async function openBrowser(address: string) {
await import('open').then((module) => module.default(address, { newInstance: true })).catch(() => {})
function openBrowser(address: string) {
opener(address)
}

const formatNumber = (number: number | string) => colors.dim(colors.bold(number))
Expand Down Expand Up @@ -152,7 +153,7 @@ function analyzer(opts: AnalyzerPluginOptions = { analyzerMode: 'server', summar
setup(foamModule, { title: reportTitle, mode: 'stat' })
if ((opts.openAnalyzer ?? true) && !isCI) {
const address = `http://localhost:${port}`
await openBrowser(address)
openBrowser(address)
}
break
}
Expand Down
Loading

0 comments on commit 0002dd7

Please sign in to comment.