Skip to content

Commit

Permalink
fix: mkcert initialization error
Browse files Browse the repository at this point in the history
  • Loading branch information
liuweiGL committed Feb 20, 2023
1 parent 80caf35 commit b8e6e96
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
9 changes: 7 additions & 2 deletions dist/mkcert.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/mkcert.js.map

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions dist/mkcert.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ var mkdir = async (dirname) => {
}
};
var ensureDirExist = async (filePath) => {
const dirname = path2.dirname(filePath);
const ext = path2.extname(filePath);
const dirname = ext ? path2.dirname(filePath) : filePath;
await mkdir(dirname);
};
var readFile = async (filePath) => {
Expand Down Expand Up @@ -466,13 +467,16 @@ var Mkcert = class {
} else if (await exists(this.savedMkcert)) {
binnary = this.savedMkcert;
}
return binnary || escape(binnary);
return binnary ? escape(binnary) : void 0;
}
async checkCAExists() {
const files = await readDir(this.savePath);
return files.some((file) => file.includes("rootCA"));
}
async retainExistedCA() {
if (await this.checkCAExists()) {
return;
}
const mkcertBinnary = await this.getMkcertBinnary();
const commandStatement = `${mkcertBinnary} -CAROOT`;
debug(`Exec ${commandStatement}`);
Expand Down Expand Up @@ -535,6 +539,7 @@ ${this.certFilePath}`
record.update({ hosts, hash });
}
async init() {
await ensureDirExist(this.savePath);
await this.config.init();
const mkcertBinnary = await this.getMkcertBinnary();
if (!mkcertBinnary) {
Expand Down
4 changes: 2 additions & 2 deletions dist/mkcert.mjs.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion plugin/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const mkdir = async (dirname: string) => {
}

export const ensureDirExist = async (filePath: string) => {
const dirname = path.dirname(filePath)
const ext = path.extname(filePath)
const dirname = ext ? path.dirname(filePath) : filePath
await mkdir(dirname)
}

Expand Down
4 changes: 2 additions & 2 deletions plugin/mkcert/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ class Mkcert {
} else if (await exists(this.savedMkcert)) {
binnary = this.savedMkcert
}

return escape(binnary)
return binnary ? escape(binnary) : undefined
}

private async checkCAExists() {
Expand Down Expand Up @@ -238,6 +237,7 @@ class Mkcert {
}

public async init() {
await ensureDirExist(this.savePath)
await this.config.init()

const mkcertBinnary = await this.getMkcertBinnary()
Expand Down

0 comments on commit b8e6e96

Please sign in to comment.