Skip to content

Commit

Permalink
fix typos and use filter(Boolean) to simplified Code (#71)
Browse files Browse the repository at this point in the history
* fix: typos

* chore: use filter(Boolean)
  • Loading branch information
yiliang114 authored Nov 20, 2023
1 parent 155ce18 commit 5ea7391
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const plugin = (options: MkcertPluginOptions = {}): PluginOption => {
allHosts.push(server.host)
}

const uniqueHosts = Array.from(new Set(allHosts)).filter(item => !!item)
const uniqueHosts = Array.from(new Set(allHosts)).filter(Boolean)

const certificate = await mkcert.install(uniqueHosts)
const httpsConfig = {
Expand Down
24 changes: 12 additions & 12 deletions plugin/mkcert/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ class Mkcert {
this.config = new Config({ savePath: this.savePath })
}

private async getMkcertBinnary() {
let binnary
private async getMkcertBinary() {
let binary

if (this.localMkcert) {
if (await exists(this.localMkcert)) {
binnary = this.localMkcert
binary = this.localMkcert
} else {
this.logger.error(
pc.red(
Expand All @@ -143,9 +143,9 @@ class Mkcert {
)
}
} else if (await exists(this.savedMkcert)) {
binnary = this.savedMkcert
binary = this.savedMkcert
}
return binnary ? escape(binnary) : undefined
return binary ? escape(binary) : undefined
}

private async checkCAExists() {
Expand All @@ -158,8 +158,8 @@ class Mkcert {
return
}

const mkcertBinnary = await this.getMkcertBinnary()
const commandStatement = `${mkcertBinnary} -CAROOT`
const mkcertBinary = await this.getMkcertBinary()
const commandStatement = `${mkcertBinary} -CAROOT`

debug(`Exec ${commandStatement}`)

Expand Down Expand Up @@ -193,9 +193,9 @@ class Mkcert {

private async createCertificate(hosts: string[]) {
const names = hosts.join(' ')
const mkcertBinnary = await this.getMkcertBinnary()
const mkcertBinary = await this.getMkcertBinary()

if (!mkcertBinnary) {
if (!mkcertBinary) {
debug(
`Mkcert does not exist, unable to generate certificate for ${names}`
)
Expand All @@ -204,7 +204,7 @@ class Mkcert {
await ensureDirExist(this.savePath)
await this.retainExistedCA()

const cmd = `${mkcertBinnary} -install -key-file ${escape(
const cmd = `${mkcertBinary} -install -key-file ${escape(
this.keyFilePath
)} -cert-file ${escape(this.certFilePath)} ${names}`

Expand Down Expand Up @@ -240,9 +240,9 @@ class Mkcert {
await ensureDirExist(this.savePath)
await this.config.init()

const mkcertBinnary = await this.getMkcertBinnary()
const mkcertBinary = await this.getMkcertBinary()

if (!mkcertBinnary) {
if (!mkcertBinary) {
await this.initMkcert()
} else if (this.autoUpgrade) {
await this.upgradeMkcert()
Expand Down

0 comments on commit 5ea7391

Please sign in to comment.