Skip to content

Commit

Permalink
fix: fix access denied error caused by JAVA_HOME
Browse files Browse the repository at this point in the history
close #15
  • Loading branch information
liuweiGL committed Feb 25, 2022
1 parent c031bc9 commit f4f7c18
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/plugin/src/lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import child_process from 'child_process'
import child_process, { ExecOptions } from 'child_process'
import fs from 'fs'
import os from 'os'
import path from 'path'
Expand Down Expand Up @@ -59,8 +59,8 @@ export const writeFile = async (
await fs.promises.chmod(filePath, 0o777)
}

export const exec = async (cmd: string) => {
return await util.promisify(child_process.exec)(cmd)
export const exec = async (cmd: string, options?: ExecOptions) => {
return await util.promisify(child_process.exec)(cmd, options)
}

export const getLocalV4Ips = () => {
Expand Down
8 changes: 7 additions & 1 deletion packages/plugin/src/mkcert/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'fs'
import process from 'process'

import chalk from 'chalk'
import { Logger } from 'vite'
Expand Down Expand Up @@ -145,7 +146,12 @@ class Mkcert {
KEY_FILE_PATH
)} -cert-file ${escape(CERT_FILE_PATH)} ${names}`

await exec(cmd)
await exec(cmd, {
env: {
...process.env,
JAVA_HOME: undefined
}
})

this.logger.info(
`The certificate is saved in:\n${KEY_FILE_PATH}\n${CERT_FILE_PATH}`
Expand Down

0 comments on commit f4f7c18

Please sign in to comment.