Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential issues with process.exit(1) #18

Closed
kitsune7 opened this issue Sep 18, 2020 · 1 comment
Closed

Potential issues with process.exit(1) #18

kitsune7 opened this issue Sep 18, 2020 · 1 comment

Comments

@kitsune7
Copy link

kitsune7 commented Sep 18, 2020

console.error is synchronous as far as I'm aware, so this may not be an issue, but I thought I would bring it up regardless. Feel free to close this issue if you think it's more work than it's worth.

In cli.js there's a code segment that uses process.exit(1) right after logging to stderr.

if (cli.input.length === 0) {
	console.error('Specify at least one path');
	process.exit(1);
}

While I don't think this would be an issue in most cases, calling process.exit(1) isn't recommended practice. It's better to use process.exitCode = 1 and then just prevent the function after it from running with else.

See this StackOverflow thread for more details.

@kitsune7 kitsune7 changed the title Potential issue with stderr getting cut short Potential issues with process.exit(1) Sep 18, 2020
@sindresorhus
Copy link
Owner

I would usually agree, but in this case, it doesn't really matter. Also, for context, this code was written before process.exitCode = was the best-practice. However, I guess, it doesn't hurt to change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants