Created by: wmonk
What has been done
- When
process.stdin
fires anend
event, the process exits with a0
exit code
How has this been tested
- Started the app normally
- Started the app when another app was already running (chose a new port)
- Started the app via phoenix
Activity
Created by: facebook-github-bot
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!
If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact cla@fb.com if you have any questions.
Created by: wmonk
I don't think this needs to happen for
build
andtest
, both of those scripts will exit once they've finished processing.To be honest, i'm not 100% familiar with what
resume()
, but has been used by all other mentioned projects to enable this behaviour. From what I have read, it essentially starts reading from the stdin stream, which it doesn't do automatically unless you explicitly callprocess.stdin.on('data', callback)
. You can test it with:$ echo "{ foo: 'bar' }" | node -e 'process.stdin.on("data", d => console.log(d.toString()))' // { foo: 'bar' } $ echo "{ foo: 'bar' }" | node -e 'process.stdin.on("end", () => console.log("hello world"))' // $ echo "{ foo: 'bar' }" | node -e 'process.stdin.on("end", () => console.log("hello world")); process.stdin.resume()' // hello world
Created by: ianmcnally
Design/style Q: would it make sense to make a helper, since this code is duplicated across two files?
Like:
// in a new dev script function addExitHandlersToProcess(process) { process.stdin.on('end', function() { process.exit(0); }); process.stdin.resume(); } }
And call it in start.js and test.js. Along with cutting down duplication, it would add some self-documentation.