package
Consistent STDIN piping, cross platform
npm install smart-pipeGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 2 packages.
39.3 kB
Includes dependencies.
Wrap STDIN buffers for programs that don't directly support stdin
The following work cross-platform.
var smartPipe = require('smart-pipe');
var exec = require('child_process').exec;
var buffer = new Buffer([1, 2, 3, 4]);
var piped = smartPipe(buffer);
var cmd = piped.command + 'xxd ' + piped.file;
var proc = exec(cmd, function(err, stdout, stderr) {
console.log(stdout);
piped.clean();
});
proc.stdin.write(piped.buffer);
proc.stdin.endvar smartPipe = require('smart-pipe');
var exec = require('child_process').execSync;
var buffer = new Buffer([1, 2, 3, 4]);
var piped = smartPipe(buffer);
var cmd = piped.command + 'xxd ' + piped.file;
var result = exec(cmd, {input: piped.buffer});
console.log(result.toString());
piped.clean();You might be wondering, this seems really overkill.
echo hello | cat) you'll need to use the filename syntax
(i.e. cat some_file.txt). This is because we pass the STDIN file descriptor
as input.LD_PRELOAD information on Linux, and be completely blank on other
platforms.clean()? This is mainly on windows, but if a temporary
file was written (on a platform that doesn't fully support STDIN), this will clean it.
If you choose not to call .clean(), temporary files will be purged upon the exit
of Node.Licensed under the MIT License. You can find a copy of it in LICENSE.