Socket
Socket
Sign inDemoInstall

node-pty

Package Overview
Dependencies
Maintainers
1
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-pty - npm Package Compare versions

Comparing version 0.7.4 to 0.7.5

17

lib/index.js

@@ -8,8 +8,8 @@ "use strict";

var path = require("path");
var Terminal;
var terminalCtor;
if (process.platform === 'win32') {
Terminal = require('./windowsTerminal').WindowsTerminal;
terminalCtor = require('./windowsTerminal').WindowsTerminal;
}
else {
Terminal = require('./unixTerminal').UnixTerminal;
terminalCtor = require('./unixTerminal').UnixTerminal;
}

@@ -28,20 +28,17 @@ /**

function spawn(file, args, opt) {
return new Terminal(file, args, opt);
return new terminalCtor(file, args, opt);
}
exports.spawn = spawn;
;
/** @deprecated */
function fork(file, args, opt) {
return new Terminal(file, args, opt);
return new terminalCtor(file, args, opt);
}
exports.fork = fork;
;
/** @deprecated */
function createTerminal(file, args, opt) {
return new Terminal(file, args, opt);
return new terminalCtor(file, args, opt);
}
exports.createTerminal = createTerminal;
;
function open(options) {
return Terminal.open(options);
return terminalCtor.open(options);
}

@@ -48,0 +45,0 @@ exports.open = open;

@@ -7,8 +7,8 @@ "use strict";

var assert = require("assert");
var PlatformTerminal;
var terminalCtor;
if (process.platform === 'win32') {
PlatformTerminal = require('./windowsTerminal');
terminalCtor = require('./windowsTerminal');
}
else {
PlatformTerminal = require('./unixTerminal');
terminalCtor = require('./unixTerminal');
}

@@ -18,3 +18,3 @@ describe('Terminal', function () {

it('should do basic type checks', function () {
assert.throws(function () { return new PlatformTerminal('a', 'b', { 'name': {} }); }, 'name must be a string (not a object)');
assert.throws(function () { return new terminalCtor('a', 'b', { 'name': {} }); }, 'name must be a string (not a object)');
});

@@ -21,0 +21,0 @@ });

@@ -19,2 +19,3 @@ "use strict";

var path = require("path");
var os = require("os");
var terminal_1 = require("./terminal");

@@ -195,6 +196,19 @@ var utils_1 = require("./utils");

UnixTerminal.prototype.kill = function (signal) {
try {
process.kill(this.pid, signal || 'SIGHUP');
if (signal === void 0) { signal = 'SIGHUP'; }
if (signal in os.constants.signals) {
try {
// pty.kill will not be available on systems which don't support
// the TIOCSIG/TIOCSIGNAL ioctl
if (pty.kill && signal !== 'SIGHUP') {
pty.kill(this._fd, os.constants.signals[signal]);
}
else {
process.kill(this.pid, signal);
}
}
catch (e) { /* swallow */ }
}
catch (e) { }
else {
throw new Error('Unknown signal: ' + signal);
}
};

@@ -201,0 +215,0 @@ Object.defineProperty(UnixTerminal.prototype, "process", {

@@ -41,3 +41,3 @@ "use strict";

var term = new unixTerminal_1.UnixTerminal('/bin/bash', ['-c', "cat \"" + FIXTURES_PATH + "\""], {
encoding: null,
encoding: null
});

@@ -44,0 +44,0 @@ term.on('data', function (data) {

@@ -7,6 +7,6 @@ {

},
"version": "0.7.4",
"version": "0.7.5",
"license": "MIT",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"types": "./typings/node-pty.d.ts",
"repository": {

@@ -37,20 +37,21 @@ "type": "git",

"tsc": "tsc",
"tslint": "tslint src/**/*.ts",
"lint": "tslint 'src/**/*.ts'",
"install": "node scripts/install.js",
"postinstall": "node scripts/post-install.js",
"test": "cross-env NODE_ENV=test mocha -R spec lib/*.test.js",
"test": "cross-env NODE_ENV=test mocha -R spec --exit lib/*.test.js",
"prepublish": "npm run tsc"
},
"dependencies": {
"nan": "^2.6.2"
"nan": "2.10.0"
},
"devDependencies": {
"@types/mocha": "^2.2.41",
"@types/node": "^6.0.58",
"cross-env": "^3.2.4",
"mocha": "^3.1.2",
"@types/mocha": "^5.0.0",
"@types/node": "^6.0.104",
"cross-env": "^5.1.4",
"mocha": "^5.0.5",
"pollUntil": "^1.0.3",
"tslint": "^4.3.1",
"typescript": "^2.1.4"
"tslint": "^5.9.1",
"tslint-consistent-codestyle": "^1.13.0",
"typescript": "^2.8.1"
}
}
# node-pty
[![Travis CI build status](https://travis-ci.org/Tyriar/node-pty.svg?branch=master)](https://travis-ci.org/Tyriar/node-pty)
[![Appveyor build status](https://ci.appveyor.com/api/projects/status/1064dcr2t2r90q4n/branch/master?svg=true)](https://ci.appveyor.com/project/Tyriar/node-pty/branch/master)
[![Build status](https://tyriar.visualstudio.com/_apis/public/build/definitions/2d361770-e039-4acc-b2b2-ef8396473589/1/badge)](https://tyriar.visualstudio.com/node-pty/_build/index?definitionId=1)

@@ -19,3 +18,3 @@ `forkpty(3)` bindings for node.js. This allows you to fork processes with pseudoterminal file descriptors. It returns a terminal object which allows reads and writes.

- [Microsoft Visual Studio Code](code.visualstudio.com)
- [Microsoft Visual Studio Code](https://code.visualstudio.com)
- [Hyper](https://hyper.is/)

@@ -25,2 +24,4 @@ - [Upterm](https://github.com/railsware/upterm)

- [Theia](https://github.com/theia-ide/theia)
- [FreeMAN](https://github.com/matthew-matvei/freeman) file manager
- [atom-xterm](https://atom.io/packages/atom-xterm) - Atom plugin for providing terminals inside your Atom workspace.

@@ -63,2 +64,10 @@ Do you use node-pty in your application as well? Please open a [Pull Request](https://github.com/Tyriar/node-pty/pulls) to include it here. We would love to have it in our list.

### Dependencies on Windows
`npm install` requires some tools to be present in the system like Python and C++ compiler. Windows users can easily install them by running the following command in PowerShell as administrator. For more information see https://github.com/felixrieseberg/windows-build-tools:
```sh
npm install --global --production windows-build-tools
```
## Debugging

@@ -82,3 +91,3 @@

Copyright (c) 2012-2015, Christopher Jeffrey (MIT License).
Copyright (c) 2012-2015, Christopher Jeffrey (MIT License).
Copyright (c) 2016, Daniel Imms (MIT License).

@@ -11,7 +11,7 @@ /**

let Terminal: any;
let terminalCtor: any;
if (process.platform === 'win32') {
Terminal = require('./windowsTerminal').WindowsTerminal;
terminalCtor = require('./windowsTerminal').WindowsTerminal;
} else {
Terminal = require('./unixTerminal').UnixTerminal;
terminalCtor = require('./unixTerminal').UnixTerminal;
}

@@ -31,17 +31,17 @@

export function spawn(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions): ITerminal {
return new Terminal(file, args, opt);
};
return new terminalCtor(file, args, opt);
}
/** @deprecated */
export function fork(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions): ITerminal {
return new Terminal(file, args, opt);
};
return new terminalCtor(file, args, opt);
}
/** @deprecated */
export function createTerminal(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions): ITerminal {
return new Terminal(file, args, opt);
};
return new terminalCtor(file, args, opt);
}
export function open(options: IPtyOpenOptions): ITerminal {
return Terminal.open(options);
return terminalCtor.open(options);
}

@@ -48,0 +48,0 @@

@@ -7,3 +7,5 @@ /**

export type ProcessEnv = {[key: string]: string};
export interface IProcessEnv {
[key: string]: string;
}

@@ -113,3 +115,3 @@ export interface ITerminal {

cwd?: string;
env?: ProcessEnv;
env?: IProcessEnv;
uid?: number;

@@ -116,0 +118,0 @@ gid?: number;

@@ -9,7 +9,7 @@ /**

let PlatformTerminal: WindowsTerminal | UnixTerminal;
let terminalCtor: WindowsTerminal | UnixTerminal;
if (process.platform === 'win32') {
PlatformTerminal = require('./windowsTerminal');
terminalCtor = require('./windowsTerminal');
} else {
PlatformTerminal = require('./unixTerminal');
terminalCtor = require('./unixTerminal');
}

@@ -21,3 +21,3 @@

assert.throws(
() => new (<any>PlatformTerminal)('a', 'b', { 'name': {} }),
() => new (<any>terminalCtor)('a', 'b', { 'name': {} }),
'name must be a string (not a object)'

@@ -24,0 +24,0 @@ );

@@ -59,3 +59,3 @@ /**

/** See net.Socket.end */
public end(data: string): void{
public end(data: string): void {
this._socket.end(data);

@@ -62,0 +62,0 @@ }

@@ -43,3 +43,3 @@ /**

const term = new UnixTerminal('/bin/bash', [ '-c', `cat "${FIXTURES_PATH}"` ], {
encoding: null,
encoding: null
});

@@ -46,0 +46,0 @@ term.on('data', (data) => {

@@ -9,12 +9,13 @@ /**

import * as tty from 'tty';
import * as os from 'os';
import { Terminal, DEFAULT_COLS, DEFAULT_ROWS } from './terminal';
import { ProcessEnv, IPtyForkOptions, IPtyOpenOptions } from './interfaces';
import { IProcessEnv, IPtyForkOptions, IPtyOpenOptions } from './interfaces';
import { ArgvOrCommandLine } from './types';
import { assign } from './utils';
declare type NativePty = {
declare interface INativePty {
master: number;
slave: number;
pty: string;
};
}

@@ -75,3 +76,3 @@ const pty = require(path.join('..', 'build', 'Release', 'pty.node'));

const onexit = (code: any, signal: any) => {
const onexit = (code: number, signal: number) => {
// XXX Sometimes a data event is emitted after exit. Wait til socket is

@@ -184,3 +185,3 @@ // destroyed.

// open
const term: NativePty = pty.open(cols, rows);
const term: INativePty = pty.open(cols, rows);

@@ -236,6 +237,16 @@ self._master = new PipeSocket(<number>term.master);

public kill(signal?: string): void {
try {
process.kill(this.pid, signal || 'SIGHUP');
} catch (e) { /* swallow */ }
public kill(signal: string = 'SIGHUP'): void {
if (signal in os.constants.signals) {
try {
// pty.kill will not be available on systems which don't support
// the TIOCSIG/TIOCSIGNAL ioctl
if (pty.kill && signal !== 'SIGHUP') {
pty.kill(this._fd, os.constants.signals[signal]);
} else {
process.kill(this.pid, signal);
}
} catch (e) { /* swallow */ }
} else {
throw new Error('Unknown signal: ' + signal);
}
}

@@ -258,3 +269,3 @@

private _sanitizeEnv(env: ProcessEnv): void {
private _sanitizeEnv(env: IProcessEnv): void {
// Make sure we didn't start our server from inside tmux.

@@ -261,0 +272,0 @@ delete env['TMUX'];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc