Skip to content

Commit

Permalink
Merge pull request #310 from microsoft/cleanup
Browse files Browse the repository at this point in the history
Clean up
  • Loading branch information
Tyriar authored May 22, 2019
2 parents 487b3ed + 7637c4d commit 5924d76
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
10 changes: 4 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* Copyright (c) 2018, Microsoft Corporation (MIT License).
*/

import * as path from 'path';
import { Terminal as BaseTerminal } from './terminal';
import { ITerminal, IPtyOpenOptions, IPtyForkOptions } from './interfaces';
import { ITerminal, IPtyOpenOptions, IPtyForkOptions, IWindowsPtyForkOptions } from './interfaces';
import { ArgvOrCommandLine } from './types';

let terminalCtor: any;
Expand All @@ -28,17 +26,17 @@ if (process.platform === 'win32') {
* @see Parsing C++ Comamnd-Line Arguments https://msdn.microsoft.com/en-us/library/17w5ykft.aspx
* @see GetCommandLine https://msdn.microsoft.com/en-us/library/windows/desktop/ms683156.aspx
*/
export function spawn(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions): ITerminal {
export function spawn(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions | IWindowsPtyForkOptions): ITerminal {
return new terminalCtor(file, args, opt);
}

/** @deprecated */
export function fork(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions): ITerminal {
export function fork(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions | IWindowsPtyForkOptions): ITerminal {
return new terminalCtor(file, args, opt);
}

/** @deprecated */
export function createTerminal(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions): ITerminal {
export function createTerminal(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions | IWindowsPtyForkOptions): ITerminal {
return new terminalCtor(file, args, opt);
}

Expand Down
17 changes: 15 additions & 2 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,24 @@ export interface IPtyForkOptions {
cols?: number;
rows?: number;
cwd?: string;
env?: IProcessEnv;
env?: { [key: string]: string };
uid?: number;
gid?: number;
encoding?: string;
experimentalUseConpty?: boolean | undefined;
handleFlowControl?: boolean;
flowControlPause?: string;
flowControlResume?: string;
}

export interface IWindowsPtyForkOptions {
name?: string;
cols?: number;
rows?: number;
cwd?: string;
env?: { [key: string]: string };
encoding?: string;
experimentalUseConpty?: boolean;
conptyInheritCursor?: boolean;
handleFlowControl?: boolean;
flowControlPause?: string;
flowControlResume?: string;
Expand Down
2 changes: 0 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* Copyright (c) 2018, Microsoft Corporation (MIT License).
*/

import * as path from 'path';

export function assign(target: any, ...sources: any[]): any {
sources.forEach(source => Object.keys(source).forEach(key => target[key] = source[key]));
return target;
Expand Down
2 changes: 1 addition & 1 deletion src/windowsPtyAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2018, Microsoft Corporation (MIT License).
*/

import * as assert from 'assert';
import * as assert from 'assert';
import { argsToCommandLine } from './windowsPtyAgent';

function check(file: string, args: string | string[], expected: string): void {
Expand Down
3 changes: 1 addition & 2 deletions src/windowsTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
import { Socket } from 'net';
import { Terminal, DEFAULT_COLS, DEFAULT_ROWS } from './terminal';
import { WindowsPtyAgent } from './windowsPtyAgent';
import { IPtyForkOptions, IPtyOpenOptions } from './interfaces';
import { IPtyOpenOptions, IWindowsPtyForkOptions } from './interfaces';
import { ArgvOrCommandLine } from './types';
import { assign } from './utils';
import { IWindowsPtyForkOptions } from 'node-pty';

const DEFAULT_FILE = 'cmd.exe';
const DEFAULT_NAME = 'Windows Shell';
Expand Down

0 comments on commit 5924d76

Please sign in to comment.