fardog / ghostface Goto Github PK
View Code? Open in Web Editor NEWEvaluate Javascript in PhantomJS, and print the output.
Home Page: https://www.npmjs.com/package/ghostface
License: Apache License 2.0
Evaluate Javascript in PhantomJS, and print the output.
Home Page: https://www.npmjs.com/package/ghostface
License: Apache License 2.0
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?
var spawn = require('child_process').spawn;
var spawned_process;
spawned_process = spawn('./node_modules/.bin/ghostface', ['test/browser_test_compiled.js']);
spawned_process.stdout.pipe(process.stdout);
spawned_process.stderr.pipe(process.stderr);
spawned_process.on('exit', function(code, signal){
console.log("EXITED with code", code);
});
spawned_process.on('error', function(err){
console.log("ERROR", err);
});
The same setup works for things like browserify, for example if I do:
spawned_process = spawn('./node_modules/.bin/browserify', ['test/browser_tes.js']);
It outputs the stdout and exits with a 0.
Any thoughts?
There is an issue with your ternary at: https://github.com/fardog/ghostface/blob/master/bin/ghostface.js#L45
function onExit(code, signal) {
if(code > 0) {
console.error(sprintf('\nphantomjs exited abnormally: %d'), code)
}
process.exit(code || signal === 'SIGTERM' ? 0 : 1)
}
Basically you're making the exit code 0
if code != 0
! (if code is truthy OR signal == 'SIGTERM' then 0 else 1)
You probably want this?
process.exit(code || (signal === 'SIGTERM' ? 0 : 1))
When phantom crashes, or when a timeout occurs, there is no difference to the CLI, it just exits with code 1; there should be a difference between a timeout, and we likely should just be passing the phantom error code directly through (rather than coercing it into a 0/1).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.