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

Feature request: option for console #5197

Open
bylee20 opened this issue Aug 9, 2016 · 7 comments
Open

Feature request: option for console #5197

bylee20 opened this issue Aug 9, 2016 · 7 comments

Comments

@bylee20
Copy link

bylee20 commented Aug 9, 2016

nw redirects console to devtool.
This behavior disables simple inter-process communication through stdout.

An option for console would be really helpful to choice behaviour.

I think 'enable redirection/disable redirection/use both of redirection and terminal output' would be fine.

As advanced requests, integration with process.stdout would be more helpful and if stdin implemented, it will be really great!

@ghostoy
Copy link
Member

ghostoy commented Aug 9, 2016

@xylosper It would be more helpful to understand your request if you can provide usage scenarios in code.

@kiavashi
Copy link

kiavashi commented Aug 9, 2016

@xylosper you could always just use process.stdout.write() directly, write a simple wrapper, or even copy the nodejs console implementation into your code

If you are using stdout for interprocess communication you'll want to write a wrapper anyways to have an identifiable format, since nwjs writes stuff to stdout too.

@bylee20
Copy link
Author

bylee20 commented Aug 10, 2016

@ghostoy
For instance, I want to do something like:

const spawn = require('child_process').spawn;
const child = spawn('nw', ['path/to/child/process']);
child.stdout.on('data', data => {
  const result = parseDataFromChildProcess(data);
  const feedback = doSomethingWithResult(result);
  child.stdin.write(makeAnFeedbackMessage(feedback);
});

For now, there's nothing retrieved from child.stdout. All terminal output of child go to the devTool of child nw instance.
And, as already known, nw does not support stdin. But stdin support is not the main concern in this feature request.

@kiavashps
I've already tested process.stdout.write() but it didn't work for neither of devTool and terminal.
Here's an sample code for child process:

index.html

<html>
<head>
<script>
    console.log('console.log');
    process.stdout.write('process.stdout.write');
</script>
</head>
<body></body>
</html>

package.json

{
    "main": "index.html",
    "name": "test"
}

When I run this in terminal(windows cmd), I cannot get nothing in terminal and I can see only 'console.log' in console of devTools.

@kiavashi
Copy link

@xylosper interesting, it works for me on mac 10.11 and nwjs v0.15.4
what nwjs and os version are you using?

@frankhale
Copy link
Contributor

I can confirm this behavior on Windows 10 using NW.js 0.16.1.

This 3 year old issue seems related: #685

@bylee20
Copy link
Author

bylee20 commented Aug 10, 2016

@kiavashps
I've tested nwjs 0.15.4, 0.16.0 and 0.16.1 on Window 8.

@frankhale
I'm not sure. They're talking about --enable-logging but when I used it, it worked well, but I got tons of debugging message from chrome which is totally useless for my purpose.
Also, they just saying that stdout doesn't work. They didn't mention neither of which method they used to log to stdout, nor in which console(devTool or terminal) they want to see the log.

@bschmitlin
Copy link

yeah, in my experience stdout doesn't work on Windows (while it works fine on other OSes). Only stderr works. Which is problematic for some loggings libraries (including https://github.com/visionmedia/debug)

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

No branches or pull requests

5 participants