New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix stdin.js #58
fix stdin.js #58
Conversation
Nice catch! Do you know the support of |
Is this really correct? Old method:
Proposed method:
I think our tests don't touch this, hence why Travis shows OK. |
@yukkurisinai @anko Interesing, they do seem to work for console.log(!process.stdin.isTTY);
console.log(require('fs').fstatSync(0).isFIFO()) Yields:
But for
|
@yukkurisinai What was the case where this failed? |
when I use mdast in drone.io, var shell = require("gulp-shell");
gulp.task("foobar", shell.task("node -e \"console.log(\!process.stdin.isTTY)\"")); when I use mdast by gulp-shell, the same thing happened at line 24.
|
In the first place, mdast check |
sorry to my poor english :( |
@yukkurisinai because when not piping in, passing no files is an error. When piping in, passing files is an error! |
ok, I understood... I thought that when passing files, mdast can ignore expectPipeIn. |
Okay, I tested a lot, it has to do with subprocesses. And I couldn’t find a method, either |
umm... If you can ignore |
But I’d rather not ignore it though! |
ok, I investigation about "<<<". please wait a moment to conclude plz... |
Yeah I’m testing it out too. Thanks for helping! |
if user use "<<<", isFIFO can't catch pipe. so, I wrote a code. var expectPipeIn = !process.stdin.isTTY || fs.fstatSync(0).isFIFO(); How is this? |
As you can see from line 6, it’s exactly the same as line 1 and 2 (meaning it |
@anko How standard is |
I was able to get almost all cases to work:
...and in gulp (see below for example code):
By only throwing if there’s definitly a TTY. However, this doesn’t work for the below case (which keeps hanging) var gulp = require('gulp');
var shell = require('gulp-shell');
var task = shell.task('mdast'); // this hangs.
gulp.task('default', task); |
Plus, the system outlined above: In bash and gulp: Throws on I’m not sure if “hanging” / waiting for stdin, in a child-process, when not given files is a big problem. I think I’ll just add it :) |
Thanks for your work and help. This ensures that at least no false errors are thrown. It will be released when GH-57 is merged. |
thank you very much! |
There’s no way to accuratly detect *if* text is going to be piped in, especially when using child-processes (e.g., in gulp) This fixes that by only throwing errors when the CLI is sure nothing is going to be piped in. See the below issue for more info. Closes GH-58.
get expectPipeIn by the right way