Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Created February 4, 2021 09:07
Show Gist options
  • Save CMCDragonkai/5473305655a76374cd2bc2b0a48ccc82 to your computer and use it in GitHub Desktop.
Save CMCDragonkai/5473305655a76374cd2bc2b0a48ccc82 to your computer and use it in GitHub Desktop.
Synchronous and Asynchronous Node.js Scripts #nodejs #javascript
#!/usr/bin/env node
import process from 'process';
async function main(argv = process.argv): Promise<number> {
process.exitCode = 0;
return process.exitCode;
}
if (require.main === module) {
(async () => {
await main();
})();
}
export default main;
#!/usr/bin/env node
import process from 'process';
function main(argv = process.argv): number {
process.exitCode = 0;
return process.exitCode;
}
if (require.main === module) {
main();
}
export default main;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment