diff --git a/pty/LICENSE b/pty/LICENSE index 3713105..22286d2 100644 --- a/pty/LICENSE +++ b/pty/LICENSE @@ -40,4 +40,29 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. + + +MIT License + +Copyright (c) 2018 - present Microsoft Corporation + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/pty/src/unixTerminal.ts b/pty/src/unixTerminal.ts index 71d4047..526205c 100644 --- a/pty/src/unixTerminal.ts +++ b/pty/src/unixTerminal.ts @@ -1,6 +1,7 @@ /** * Copyright (c) 2012-2015, Christopher Jeffrey (MIT License) * Copyright (c) 2016, Daniel Imms (MIT License). + * Copyright (c) 2018, Microsoft Corporation (MIT License). */ import * as net from 'net'; @@ -263,10 +264,19 @@ export class UnixTerminal extends Terminal { */ class PipeSocket extends net.Socket { constructor(fd: any) { - const tty = (process).binding('tty_wrap'); - const guessHandleType = tty.guessHandleType; - tty.guessHandleType = () => 'PIPE'; - super({ fd }); - tty.guessHandleType = guessHandleType; + if (parseInt(process.versions.modules) < 72) { + const tty = (process).binding('tty_wrap'); + const guessHandleType = tty.guessHandleType; + tty.guessHandleType = () => 'PIPE'; + super({ fd }); + tty.guessHandleType = guessHandleType; + } else { + // This code is take from here: https://github.com/microsoft/node-pty/blob/master/src/unixTerminal.ts + const { Pipe, constants } = (process).binding('pipe_wrap'); // tslint:disable-line + // @types/node has fd as string? https://github.com/DefinitelyTyped/DefinitelyTyped/pull/18275 + const handle = new Pipe(constants.SOCKET); + handle.open(fd); + super({ handle }); + } } }