-
Notifications
You must be signed in to change notification settings - Fork 1
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
Odd behaviour when spawning ghostface with child_process.spawn #12
Comments
Hmm; I haven't tried this, but I bet this is due to how This isn't ideal, and I'll leave this issue open and check into it further. However for your use case, you may find it much simpler: var fs = require('fs')
var path = require('path')
var ghostface = require('ghostface')
var options = {
html: path.join(__dirname, 'file.html'),
timeout: 1000,
input: fs.createReadStream(path.join(__dirname, 'file.js')),
phantomPath: '/usr/sbin/phantomjs'
}
ghostface(options, process, function(code, signal) {
if(code > 0) {
console.error(sprintf('\nphantomjs exited abnormally: %d'), code)
}
process.exit(code || signal === 'SIGTERM' ? 0 : 1)
}) …admittedly, this is not a very clean interface, but it wasn't intended for public consumption (yet!). Let me know if you think that'll work for you, and like I say, I'll leave this issue open as a reminder to:
|
oh, and a quick note on the above: the {
stdin: readableStream,
stderr: writableStream,
stdout: writableStream
} You don't have to specifically pass in the process object, but that's possibly easiest for what you're looking to do. You can see how I very simply mock this object in the tests: https://github.com/fardog/ghostface/blob/master/test/index.js#L175 |
This actually does work for my situation. Thank you! While it isn't ideal, it works for me. And while I can personally work around the issue, maybe other people won't be able to, so keeping the issue open is probably a good idea :D Also, piping into the CLI is what I tried to do initially, and it works for me too, except even that wasn't exiting with proper error codes either. BUT I filed a bug report for that. Super cool that this can be used with a require! |
Hi there,
I'm trying to spawn
ghostface
using child_process.spawn().It's strange because none of the output is getting piped to the console, nor do any exit events trigger.
My guess is that the main
ghostface
isn't the process actually producing the output, nor the exit codes. Is there some other sub-process generating the output?The same setup works for things like browserify, for example if I do:
It outputs the stdout and exits with a 0.
Any thoughts?
The text was updated successfully, but these errors were encountered: