Skip to content

Commit 2ccce41

Browse files
committed
perf: update code style
1 parent e1fb6ee commit 2ccce41

File tree

16 files changed

+100
-101
lines changed

16 files changed

+100
-101
lines changed

dist/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type PluginOption } from 'vite';
2-
import { MkcertBaseOptions } from './mkcert/index';
2+
import { type MkcertBaseOptions } from './mkcert/index';
33
export { BaseSource, type SourceInfo } from './mkcert/source';
44
export type MkcertPluginOptions = MkcertBaseOptions & {
55
/**

dist/lib/util.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/// <reference types="node" />
2-
import { ExecOptions } from 'child_process';
1+
import { type ExecOptions } from 'node:child_process';
32
/**
43
* Check if file exists
54
*
@@ -22,4 +21,4 @@ export declare const getDefaultHosts: () => string[];
2221
export declare const getHash: (filePath: string) => Promise<string>;
2322
export declare const deepMerge: (target: any, ...source: any[]) => any;
2423
export declare const prettyLog: (obj?: Record<string, any>) => string;
25-
export declare const escape: (path?: string) => string;
24+
export declare const escapeStr: (path?: string) => string;

dist/mkcert.js

Lines changed: 39 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mkcert.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mkcert.mjs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
import { createLogger } from "vite";
33

44
// plugin/lib/constant.ts
5-
import os from "os";
6-
import path from "path";
5+
import os from "node:os";
6+
import path from "node:path";
77
var PKG_NAME = "vite-plugin-mkcert";
88
var PLUGIN_NAME = PKG_NAME.replace(/-/g, ":");
99
var PLUGIN_DATA_DIR = path.join(os.homedir(), `.${PKG_NAME}`);
1010

1111
// plugin/lib/util.ts
12-
import child_process from "child_process";
13-
import crypto from "crypto";
14-
import fs from "fs";
15-
import os2 from "os";
16-
import path2 from "path";
17-
import util from "util";
12+
import child_process from "node:child_process";
13+
import crypto from "node:crypto";
14+
import fs from "node:fs";
15+
import os2 from "node:os";
16+
import path2 from "node:path";
17+
import util from "node:util";
1818
var exists = async (filePath) => {
1919
try {
2020
await fs.promises.access(filePath);
2121
return true;
22-
} catch (error) {
22+
} catch (_error) {
2323
return false;
2424
}
2525
};
@@ -110,21 +110,21 @@ var deepMerge = (target, ...source) => {
110110
var prettyLog = (obj) => {
111111
return JSON.stringify(obj, null, 2);
112112
};
113-
var escape = (path5) => {
113+
var escapeStr = (path5) => {
114114
return `"${path5}"`;
115115
};
116116

117117
// plugin/mkcert/index.ts
118-
import path4 from "path";
119-
import process2 from "process";
118+
import path4 from "node:path";
119+
import process2 from "node:process";
120120
import pc from "picocolors";
121121

122122
// plugin/lib/logger.ts
123123
import Debug from "debug";
124124
var debug = Debug(PLUGIN_NAME);
125125

126126
// plugin/mkcert/config.ts
127-
import path3 from "path";
127+
import path3 from "node:path";
128128
var CONFIG_FILE_NAME = "config.json";
129129
var Config = class {
130130
/**
@@ -450,7 +450,7 @@ var Mkcert = class _Mkcert {
450450
} else if (await exists(this.savedMkcert)) {
451451
binary = this.savedMkcert;
452452
}
453-
return binary ? escape(binary) : void 0;
453+
return binary;
454454
}
455455
async checkCAExists() {
456456
const files = await readDir(this.savePath);
@@ -461,7 +461,7 @@ var Mkcert = class _Mkcert {
461461
return;
462462
}
463463
const mkcertBinary = await this.getMkcertBinary();
464-
const commandStatement = `${escape(mkcertBinary)} -CAROOT`;
464+
const commandStatement = `${escapeStr(mkcertBinary)} -CAROOT`;
465465
debug(`Exec ${commandStatement}`);
466466
const commandResult = await exec(commandStatement);
467467
const caDirPath = path4.resolve(
@@ -494,9 +494,9 @@ var Mkcert = class _Mkcert {
494494
}
495495
await ensureDirExist(this.savePath);
496496
await this.retainExistedCA();
497-
const cmd = `${escape(mkcertBinary)} -install -key-file ${escape(
497+
const cmd = `${escapeStr(mkcertBinary)} -install -key-file ${escapeStr(
498498
this.keyFilePath
499-
)} -cert-file ${escape(this.certFilePath)} ${names}`;
499+
)} -cert-file ${escapeStr(this.certFilePath)} ${names}`;
500500
await exec(cmd, {
501501
env: {
502502
...process2.env,
@@ -581,7 +581,7 @@ ${this.certFilePath}`
581581
async renew(hosts) {
582582
const record = new record_default({ config: this.config });
583583
if (this.force) {
584-
debug(`Certificate is forced to regenerate`);
584+
debug("Certificate is forced to regenerate");
585585
await this.regenerate(record, hosts);
586586
}
587587
if (!record.contains(hosts)) {

dist/mkcert.mjs.map

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

dist/mkcert/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Logger } from 'vite';
2-
import { BaseSource } from './source';
1+
import type { Logger } from 'vite';
2+
import { type BaseSource } from './source';
33
export type SourceType = 'github' | 'coding' | BaseSource;
44
export type MkcertBaseOptions = {
55
/**

dist/mkcert/record.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import Config, { RecordHash, RecordMate } from './config';
1+
import type Config from './config';
2+
import type { RecordHash, RecordMate } from './config';
23
export type RecordProps = {
34
config: Config;
45
};

dist/mkcert/version.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Config from './config';
1+
import type Config from './config';
22
export type VersionMangerProps = {
33
config: Config;
44
};

plugin/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createLogger, type PluginOption } from 'vite'
22

33
import { PLUGIN_NAME } from './lib/constant'
44
import { getDefaultHosts } from './lib/util'
5-
import Mkcert, { MkcertBaseOptions } from './mkcert/index'
5+
import Mkcert, { type MkcertBaseOptions } from './mkcert/index'
66

77
export { BaseSource, type SourceInfo } from './mkcert/source'
88

0 commit comments

Comments
 (0)