refactor: reduce repeated code in which() (#659)
refactor: reduce repeated code in which() (#659)

Use path.delimiter instead of explicit conditional. Try to reuse
repeated code blocks.

Fixes #656
shelljs/shelljs,arturadib/shelljs,psema4/shelljs