Ethlint icon indicating copy to clipboard operation
Ethlint copied to clipboard

cli input from stdin will fail in windows environment

Open duaraghav8 opened this issue 8 years ago • 4 comments

https://github.com/duaraghav8/Solium/blob/d6bba6465b6c12fc07efd325c9df29f1e78f3cf9/lib/cli.js#L178

input is currently being read using fs module from /dev/stdin - wat!? Okay so the named pipe will obviously be available in Linux environments, but not in windows. Need to account for environment in which solium is running.

duaraghav8 avatar Jun 11 '17 18:06 duaraghav8

process.stdin should work in all environments.

federicobond avatar Jun 12 '17 02:06 federicobond

So I dug deeper into this. The aim here is to read the source code from stdin synchronously. This is done perfectly as of now (var sourceCode = fs.readFileSync ('/dev/stdin', 'utf-8');), but it won't work for windows. This piece is straightforward and keeps things clean, but is asynchronous. So we'd have to introduce callbacks/promises at a lot of places.

This is a WIP.

duaraghav8 avatar Jun 13 '17 11:06 duaraghav8

Yes, get used to using callbacks and promises a lot. node is not meant for synchronous stuff.

One alternative (once you configure Babel for ES6) is to use async/await.

federicobond avatar Jun 14 '17 18:06 federicobond

This is how ESLint does it:

https://github.com/eslint/eslint/blob/6791d189da84bd1a06b326e645f021e4a74bd2e0/bin/eslint.js#L59-L75

It's styll async, but they do it before calling the main execute method. Maybe something like that could be done in bin/solium.js?

fvictorio avatar Oct 14 '17 11:10 fvictorio