Skip to content

Instantly share code, notes, and snippets.

@abhishekr700
Last active August 31, 2018 16:10
Show Gist options
  • Save abhishekr700/09bfd3cd08fd5a38f0658c5760ffc630 to your computer and use it in GitHub Desktop.
Save abhishekr700/09bfd3cd08fd5a38f0658c5760ffc630 to your computer and use it in GitHub Desktop.

Terminate an application

process.exit([code])
Ends the process with the specified code.
If omitted, exit uses the 'success' code 0.
To exit with a 'failure' code: process.exit(1);
The shell that executed node should see the exit code as 1.


Check if a file exists

var fs = require('fs');
if (fs.existsSync(path)) {
    // Do something
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment