I was wondering what the code at the end of most deploy scripts does (the .then.... parts) #2858
-
Hello, so I am not able to understand what this code does,
I tried console logging So my question is, what exactly does calling the Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello, The
Calling Hope that helps! Happy coding! |
Beta Was this translation helpful? Give feedback.
Hello,
The
process
is an object that's specific to the node.js runtime. You can find documentation about it here https://nodejs.org/api/process.htmlmain
is a promise https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise .then
is called when the promise is settled whilecatch
is called if an error happens.Calling
main
makes sure that our deploy script actually runs. Once all our code finishes, we callprocess. exit(0)
to close the runtime since nothing is left to execute. The 0 and 1 params we pass toexit
are status codes https://stackoverflow.com/questions/43147330/what-is-difference-between-method-process-exit1-and-process-exit0-in-node-jsHope that…