How would I be able to run the refresh command from a JS file?
On the server-side in a JS file you can use a child_process and exec() to run a command. See https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback for details and examples