Skip to content

Commit

Permalink
Use | undefined for process env
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Mar 30, 2021
1 parent 3142b11 commit 0588def
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
* Copyright (c) 2018, Microsoft Corporation (MIT License).
*/

import * as net from 'net';

export interface IProcessEnv {
[key: string]: string;
[key: string]: string | undefined;
}

export interface ITerminal {
Expand Down Expand Up @@ -101,7 +99,7 @@ interface IBasePtyForkOptions {
cols?: number;
rows?: number;
cwd?: string;
env?: { [key: string]: string };
env?: IProcessEnv;
encoding?: string;
handleFlowControl?: boolean;
flowControlPause?: string;
Expand Down
3 changes: 3 additions & 0 deletions src/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ export abstract class Terminal implements ITerminal {
const pairs = [];

for (let i = 0; i < keys.length; i++) {
if (keys[i] === undefined) {
continue;
}
pairs.push(keys[i] + '=' + env[keys[i]]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/unixTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class UnixTerminal extends Terminal {
this._rows = opt.rows || DEFAULT_ROWS;
const uid = opt.uid || -1;
const gid = opt.gid || -1;
const env = assign({}, opt.env);
const env: IProcessEnv = assign({}, opt.env);

if (opt.env === process.env) {
this._sanitizeEnv(env);
Expand Down
2 changes: 1 addition & 1 deletion typings/node-pty.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ declare module 'node-pty' {
/**
* Environment to be set for the child program.
*/
env?: { [key: string]: string };
env?: { [key: string]: string | undefined };

/**
* String encoding of the underlying pty.
Expand Down

0 comments on commit 0588def

Please sign in to comment.