Skip to content

Commit d0eb2e2

Browse files
committed
Fix support for non-win os env path vars
1 parent 6bfb47e commit d0eb2e2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/plugin.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import * as path from 'path'
44
function plugin(options: plugin.Options): OutputOptions {
55
const binPath = path.join(__dirname, '../bin')
66

7-
if (!(process.env.Path && process.env.Path.indexOf(binPath) !== -1))
8-
process.env.Path = (process.env.Path ?? '') + `${process.env.Path && !process.env.Path.endsWith(';') ? ';' : ''}${binPath}`
7+
const envPathSep = process.platform === 'win32' ? ';' : ':'
8+
const envPathName = process.platform === 'win32' ? 'Path' : 'PATH'
9+
10+
if (!(process.env[envPathName] && process.env[envPathName]?.indexOf(binPath) !== -1))
11+
process.env[envPathName] = (process.env[envPathName] ?? '') + `${process.env[envPathName] && !process.env[envPathName]?.endsWith(envPathSep) ? envPathSep : ''}${binPath}`
912

1013
return {
1114
name: 'grpc-web',

0 commit comments

Comments
 (0)