From d2fe441efbecf6fa354dfba34f34aa2b4bae8b59 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Wed, 22 Feb 2012 13:44:32 -0300 Subject: [PATCH] Simplified interface. --- README.md | 4 ++-- lib/pty.js | 2 ++ test/index.js | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d5252a3..a900715 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ This is useful for: ## Example Usage ``` js -var Terminal = require('pty.js'); +var spawn = require('pty.js'); -var term = new Terminal('bash', ['-i'], { +var term = spawn('bash', ['-i'], { name: 'xterm-color', cols: 80, rows: 30, diff --git a/lib/pty.js b/lib/pty.js index 9e994b7..497b72b 100644 --- a/lib/pty.js +++ b/lib/pty.js @@ -21,6 +21,8 @@ var pty = require('../pty.node'); // }); var Terminal = function(file, args, opt) { + if (!(this instanceof Terminal)) return new Terminal(file, args, opt); + var self = this , env , cwd diff --git a/test/index.js b/test/index.js index 7bd6a62..c72a6a6 100644 --- a/test/index.js +++ b/test/index.js @@ -22,3 +22,6 @@ setTimeout(function() { process.exit(0); }, 200); }, 200); + +// assert static constructor works +assert.equal(Terminal('sh', [], { name: 'test' }).name, 'test');