🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

node-pty

Package Overview
Dependencies
Maintainers
2
Versions
172
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

to
1.1.0-beta3

3

lib/unixTerminal.js

@@ -249,3 +249,4 @@ "use strict";

if (process.platform === 'darwin') {
return pty.process(this._pid) || this._file;
var title = pty.process(this._fd);
return (title !== 'kernel_task') ? title : this._file;
}

@@ -252,0 +253,0 @@ return pty.process(this._fd, this._pty) || this._file;

@@ -258,2 +258,25 @@ "use strict";

});
it('should return the name of the sub process', function (done) {
var data = "\n var pty = require('./lib/index');\n var ptyProcess = pty.spawn('zsh', ['-c', 'python3'], {\n env: process.env\n });\n ptyProcess.on('data', function (data) {\n if (ptyProcess.process === 'Python') {\n console.log('title', ptyProcess.process);\n }\n });\n setTimeout(() => null, 500);\n console.log('ready', ptyProcess.pid);\n ";
var p = cp.spawn('node', ['-e', data]);
var sub = '';
var pid = '';
p.stdout.on('data', function (data) {
if (!data.toString().indexOf('title')) {
sub = data.toString().split(' ')[1].slice(0, -1);
setTimeout(function () {
process.kill(parseInt(pid), 'SIGINT');
p.kill('SIGINT');
}, 200);
}
else if (!data.toString().indexOf('ready')) {
pid = data.toString().split(' ')[1].slice(0, -1);
}
});
p.on('exit', function () {
assert.notStrictEqual(pid, '');
assert.strictEqual(sub, 'Python');
done();
});
});
it('should close on exec', function (done) {

@@ -260,0 +283,0 @@ var data = "\n var pty = require('./lib/index');\n var ptyProcess = pty.spawn('node', ['-e', 'setTimeout(() => console.log(\"hello from terminal\"), 300);']);\n ptyProcess.on('data', function (data) {\n console.log(data);\n });\n setTimeout(() => null, 500);\n console.log('ready', ptyProcess.pid);\n ";

@@ -7,3 +7,3 @@ {

},
"version": "1.1.0-beta2",
"version": "1.1.0-beta3",
"license": "MIT",

@@ -10,0 +10,0 @@ "main": "./lib/index.js",

@@ -24,4 +24,3 @@ /**

open(cols: number, rows: number): IUnixOpenProcess;
process(fd: number, pty: string): string;
process(pid: number): string;
process(fd: number, pty?: string): string;
resize(fd: number, cols: number, rows: number): void;

@@ -28,0 +27,0 @@ }

@@ -14,2 +14,3 @@ /**

import { pollUntil } from './testUtils.test';
import { pid } from 'process';

@@ -266,2 +267,36 @@ const FIXTURES_PATH = path.normalize(path.join(__dirname, '..', 'fixtures', 'utf8-character.txt'));

});
it('should return the name of the sub process', (done) => {
const data = `
var pty = require('./lib/index');
var ptyProcess = pty.spawn('zsh', ['-c', 'python3'], {
env: process.env
});
ptyProcess.on('data', function (data) {
if (ptyProcess.process === 'Python') {
console.log('title', ptyProcess.process);
}
});
setTimeout(() => null, 500);
console.log('ready', ptyProcess.pid);
`;
const p = cp.spawn('node', ['-e', data]);
let sub = '';
let pid = '';
p.stdout.on('data', (data) => {
if (!data.toString().indexOf('title')) {
sub = data.toString().split(' ')[1].slice(0, -1);
setTimeout(() => {
process.kill(parseInt(pid), 'SIGINT');
p.kill('SIGINT');
}, 200);
} else if (!data.toString().indexOf('ready')) {
pid = data.toString().split(' ')[1].slice(0, -1);
}
});
p.on('exit', () => {
assert.notStrictEqual(pid, '');
assert.strictEqual(sub, 'Python');
done();
});
});
it('should close on exec', (done) => {

@@ -268,0 +303,0 @@ const data = `

@@ -266,3 +266,4 @@ /**

if (process.platform === 'darwin') {
return pty.process(this._pid) || this._file;
const title = pty.process(this._fd);
return (title !== 'kernel_task' ) ? title : this._file;
}

@@ -269,0 +270,0 @@

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