Skip to content

Commit 0b073c7

Browse files
committed
feat: prevent showing info box multiple times
1 parent 6371427 commit 0b073c7

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

src/plugin.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ type PluginOptions = {
1919
* @returns a Vite plugin
2020
*/
2121
export default function DevcertPlugin(options: PluginOptions = {}): Plugin {
22+
let didShowInfo = false;
23+
2224
return {
2325
name: '@idleberg/vite-plugin-devcert',
2426
config: async (userConfig: UserConfig, { command }) => {
@@ -36,16 +38,20 @@ export default function DevcertPlugin(options: PluginOptions = {}): Plugin {
3638

3739
const domain = server?.host && typeof server.host === 'string' ? server.host : 'localhost';
3840

39-
console.info(
40-
box(
41-
// Keep lines short for better readability
42-
[
43-
`Generating a certificate for "${cyan(domain)}".`,
44-
'You may be prompted to enter your password to allow the creation of a root certificate authority.',
45-
`\n\nFor details, please refer to the Expo documentation at ${underline('https://github.com/expo/devcert#how-it-works')}.`,
46-
].join(' '),
47-
),
48-
);
41+
if (!didShowInfo) {
42+
console.info(
43+
box(
44+
// Keep lines short for better readability
45+
[
46+
`Generating a certificate for "${cyan(domain)}".`,
47+
'You may be prompted to enter your password to allow the creation of a root certificate authority.',
48+
`\n\nFor details, please refer to the Expo documentation at ${underline('https://github.com/expo/devcert#how-it-works')}.`,
49+
].join(' '),
50+
),
51+
);
52+
53+
didShowInfo = true;
54+
}
4955

5056
const { key, cert } = await certificateFor(domain, options);
5157

0 commit comments

Comments
 (0)