Skip to content

Commit effcac5

Browse files
committed
feat: add hideInfoBox option
1 parent a3ef820 commit effcac5

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ If `certutil` is not installed already (for updating NSS databases; e.g. Firefox
5050

5151
Do not update your systems host file with the domain name of the certificate. [Read the Expo documentation for more](https://github.com/expo/devcert#skipcertutil).
5252

53+
#### `options.hideInfoBox`
54+
55+
Hide the info box displayed at startup.
56+
5357
## Related 👫
5458

5559
- [vite-plugin-basic-ssl](https://www.npmjs.com/package/@vitejs/plugin-basic-ssl)

src/plugin.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import logSymbols from 'log-symbols';
77
import type { Plugin, UserConfig } from 'vite';
88

99
type PluginOptions = {
10+
hideInfoBox?: boolean;
1011
skipHostsFile?: boolean;
1112
skipCertutil?: boolean;
1213
};
@@ -19,8 +20,6 @@ type PluginOptions = {
1920
* @returns a Vite plugin
2021
*/
2122
export default function DevcertPlugin(options: PluginOptions = {}): Plugin {
22-
let didShowInfo = false;
23-
2423
return {
2524
name: '@idleberg/vite-plugin-devcert',
2625
config: async (userConfig: UserConfig, { command }) => {
@@ -37,8 +36,9 @@ export default function DevcertPlugin(options: PluginOptions = {}): Plugin {
3736
}
3837

3938
const domain = server?.host && typeof server.host === 'string' ? server.host : 'localhost';
39+
const { hideInfoBox, ...certOptions } = options;
4040

41-
if (!didShowInfo) {
41+
if (Boolean(hideInfoBox) === false) {
4242
console.info(
4343
box(
4444
// Keep lines short for better readability
@@ -49,11 +49,9 @@ export default function DevcertPlugin(options: PluginOptions = {}): Plugin {
4949
].join(' '),
5050
),
5151
);
52-
53-
didShowInfo = true;
5452
}
5553

56-
const { key, cert } = await certificateFor(domain, options);
54+
const { key, cert } = await certificateFor(domain, certOptions);
5755

5856
return {
5957
...userConfig,

0 commit comments

Comments
 (0)