@yarnpkg/shell
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -13,2 +13,43 @@ "use strict"; | ||
const pipe_2 = require("./pipe"); | ||
var StreamType; | ||
(function (StreamType) { | ||
StreamType[StreamType["Readable"] = 1] = "Readable"; | ||
StreamType[StreamType["Writable"] = 2] = "Writable"; | ||
})(StreamType || (StreamType = {})); | ||
function getFileDescriptorStream(fd, type, state) { | ||
const stream = new stream_1.PassThrough({ autoDestroy: true }); | ||
switch (fd) { | ||
case pipe_1.Pipe.STDIN: | ||
{ | ||
if ((type & StreamType.Readable) === StreamType.Readable) | ||
state.stdin.pipe(stream, { end: false }); | ||
if ((type & StreamType.Writable) === StreamType.Writable && state.stdin instanceof stream_1.Writable) { | ||
stream.pipe(state.stdin, { end: false }); | ||
} | ||
} | ||
break; | ||
case pipe_1.Pipe.STDOUT: | ||
{ | ||
if ((type & StreamType.Readable) === StreamType.Readable) | ||
state.stdout.pipe(stream, { end: false }); | ||
if ((type & StreamType.Writable) === StreamType.Writable) { | ||
stream.pipe(state.stdout, { end: false }); | ||
} | ||
} | ||
break; | ||
case pipe_1.Pipe.STDERR: | ||
{ | ||
if ((type & StreamType.Readable) === StreamType.Readable) | ||
state.stderr.pipe(stream, { end: false }); | ||
if ((type & StreamType.Writable) === StreamType.Writable) { | ||
stream.pipe(state.stderr, { end: false }); | ||
} | ||
} | ||
break; | ||
default: { | ||
throw new Error(`Bad file descriptor: ${fd}`); | ||
} | ||
} | ||
return stream; | ||
} | ||
function cloneState(state, mergeWith = {}) { | ||
@@ -37,2 +78,5 @@ const newState = { ...state, ...mergeWith }; | ||
}], | ||
[`:`, async (args, opts, state) => { | ||
return 0; | ||
}], | ||
[`true`, async (args, opts, state) => { | ||
@@ -92,2 +136,7 @@ return 0; | ||
break; | ||
case `<&`: | ||
{ | ||
inputs.push(() => getFileDescriptorStream(Number(args[u]), StreamType.Readable, state)); | ||
} | ||
break; | ||
case `>`: | ||
@@ -103,2 +152,10 @@ { | ||
break; | ||
case `>&`: | ||
{ | ||
outputs.push(getFileDescriptorStream(Number(args[u]), StreamType.Writable, state)); | ||
} | ||
break; | ||
default: { | ||
throw new Error(`Unsupported redirection type: "${type}"`); | ||
} | ||
} | ||
@@ -105,0 +162,0 @@ } |
@@ -5,2 +5,3 @@ /// <reference types="node" /> | ||
export declare enum Pipe { | ||
STDIN = 0, | ||
STDOUT = 1, | ||
@@ -7,0 +8,0 @@ STDERR = 2 |
@@ -9,2 +9,3 @@ "use strict"; | ||
(function (Pipe) { | ||
Pipe[Pipe["STDIN"] = 0] = "STDIN"; | ||
Pipe[Pipe["STDOUT"] = 1] = "STDOUT"; | ||
@@ -59,3 +60,3 @@ Pipe[Pipe["STDERR"] = 2] = "STDERR"; | ||
break; | ||
case `EACCESS`: | ||
case `EACCES`: | ||
{ | ||
@@ -62,0 +63,0 @@ stdio[2].write(`permission denied: ${name}\n`); |
{ | ||
"name": "@yarnpkg/shell", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"license": "BSD-2-Clause", | ||
@@ -8,4 +8,4 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"@yarnpkg/fslib": "^2.2.2", | ||
"@yarnpkg/parsers": "^2.2.1", | ||
"@yarnpkg/fslib": "^2.3.0", | ||
"@yarnpkg/parsers": "^2.3.0", | ||
"clipanion": "^2.6.2", | ||
@@ -12,0 +12,0 @@ "cross-spawn": "7.0.3", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49102
1273
Updated@yarnpkg/fslib@^2.3.0
Updated@yarnpkg/parsers@^2.3.0