Skip to content
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

No output for mkcat <filename> #1

Open
chocolateboy opened this issue Jun 14, 2018 · 3 comments
Open

No output for mkcat <filename> #1

chocolateboy opened this issue Jun 14, 2018 · 3 comments

Comments

@chocolateboy
Copy link

mkcat1.1.5
nodev10.1.0, v10.4.1
OSLinux (Arch)

(Moved from mkdoc/mkdoc#1)

The README states that the usage for mkcat is:

mkcat README.md | mkout

But it appears to ignore the filename argument, and produces no output:

$ mkcat README.md | wc -l
0

This works:

$ cat README.md | mkcat

So I would expect this to work as well:

$ mkcat < README.md

- which it does, in part (it produces the expected output), but it also dies with an error:

node_modules/mkdoc/cli/cat.js:70
      process.stdin.end();
                    ^

TypeError: process.stdin.end is not a function
    at StreamCaller.done (node_modules/mkdoc/cli/cat.js:70:21)
    at Object.onceWrapper (events.js:273:13)
    at StreamCaller.emit (events.js:182:13)
    at done (node_modules/mkdoc/node_modules/mkcat/index.js:121:13)
    at StreamCaller.<anonymous> (node_modules/mkdoc/node_modules/mkcat/index.js:169:5)
    at Object.onceWrapper (events.js:273:13)
    at StreamCaller.emit (events.js:187:15)
    at finishMaybe (_stream_writable.js:644:14)
    at endWritable (_stream_writable.js:652:3)
    at StreamCaller.Writable.end (_stream_writable.js:592:5)
@tmpfs
Copy link
Contributor

tmpfs commented Jun 15, 2018

Thanks for the report @chocolateboy, I have reproduced this problem. It appears to be to do with the node 10.x.x releases and possibly some changes to Buffer handling, I am seeing this:

(node:7958) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

I can confirm it works as expected on 8.9.0.

I will need to look in to this some more to determine the scope of changes that would be required to support 10.x.x.

@tmpfs
Copy link
Contributor

tmpfs commented Jun 18, 2018

I can confirm that the tests pass in 9.11.2 and that the problem appears to be related to changes to stdin handling in the 10.x.x series.

It is also related to trying to combine stdin with files in the same style as cat(1), ie, you do not need to give the - argument to also read from stdin.

I can quickly hack it by testing for - in the arguments list but that introduces an ENOTCONN error (which appears to be a red herring - the AST is printed as expected and the error is thrown at the end).

I am not convinced that it is worth me spending the time on this until a 10 LTS version is released as this may well get fixed upstream and you can continue to use mkdoc with 8 and 9 for the moment.

Looking at the 10 changelog I see this PR with two changes to stdin:

nodejs/node#19377

I am unsure whether to raise an issue upstream.

Thoughts @chocolateboy?

@chocolateboy
Copy link
Author

It is also related to trying to combine stdin with files in the same style as cat(1), ie, you do not need to give the - argument to also read from stdin.

I can quickly hack it by testing for - in the arguments list

If there's an issue supporting both (stdin and argv), maybe drop support for stdin? The documentation suggests it doesn't work reliably:

It can also accept input from stdin:

cat file.md | mkcat | mkout

However this is not recommended because file path information is lost which is important for some processing tools such as mkpi which uses the file path to resolve relative include files.

- and it's easy to work, around e.g. by using tmpin:

$ cat file.md | tmpin mkcat | mkout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants