Skip to content

Commit

Permalink
Add type check for cwd
Browse files Browse the repository at this point in the history
Part of #55
  • Loading branch information
Tyriar committed Mar 24, 2017
1 parent 16a36a8 commit 4ad2860
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/terminal.ts
Expand Up @@ -6,7 +6,7 @@
import * as path from 'path';
import { Socket } from 'net';
import { EventEmitter } from 'events';
import { ITerminal } from './interfaces';
import { ITerminal, IPtyForkOptions } from './interfaces';

export abstract class Terminal implements ITerminal {
protected static readonly DEFAULT_COLS: number = 80;
Expand All @@ -27,7 +27,12 @@ export abstract class Terminal implements ITerminal {

protected _internalee: EventEmitter;

constructor() {
constructor(opt?: IPtyForkOptions) {
// TODO: Fill in more type checks
if (opt.cwd && typeof opt.cwd !== 'string') {
throw new Error('cwd must be a string');
}

// for 'close'
this._internalee = new EventEmitter();
}
Expand Down
2 changes: 1 addition & 1 deletion src/unixTerminal.ts
Expand Up @@ -33,7 +33,7 @@ export class UnixTerminal extends Terminal {
private slave: any;

constructor(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions) {
super();
super(opt);

if (typeof args === 'string') {
throw new Error('args as a string is not supported on unix.');
Expand Down

0 comments on commit 4ad2860

Please sign in to comment.