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');