Download file using curl in Nodejs

I’m trying to download a file using and API endpoint. The following command works in CMD:
curl http://localhost:8042/endpoint/file > file.extension

How can I include this command in NodeJS?
I’ve tried using node-libcurl but I can’t set the name of the file.
Any ideas?

Answer

@Lawrence Cherone
This works amazingly.
require("child_process").exec("curl ... > file.extension")