Skip to content

Commit

Permalink
feat: support auto setup Windows env
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed May 3, 2024
1 parent fa7321f commit 3fd2471
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ export interface Module {
const setupEnv = (variant?: string) => {
const postfix = variant ? `-${variant}` : ''
const binPath = path.resolve(__dirname, `../bin/${process.platform}${postfix}/${process.arch}/`)
if (!process.env.PATH?.includes(binPath)) {
process.env.PATH = `${binPath}:${process.env.PATH}`
const systemPathEnv = process.env.PATH ?? process.env.Path ?? ''
if (!systemPathEnv.includes(binPath)) {
if (process.platform === 'win32') {
process.env.Path = `${binPath};${systemPathEnv}`
} else {
process.env.PATH = `${binPath}:${systemPathEnv}`
}
}
}

Expand Down

0 comments on commit 3fd2471

Please sign in to comment.