Determines if a program exists in the PATH environment variable. Cross platform, including support for checking likely executable file extensions on Windows. Available in synchronous and asynchronous versions. Thorough unit tests included.
npm install haz
Here's a synchronous example:
var haz = require('haz');
if (haz('convert')) {
// Great, use spawn to run imagemagick's convert
}
And here's an asynchronous example with a callback:
var haz = require('haz');
haz('convert', function(result) {
if (result) {
// Great, use spawn to run imagemagick's convert
}
});
If you don't pass a callback, it behaves synchronously. Simple, right?
npm test
The tests convince haz
that is running in a realistic Windows environment for the Windows tests, and do the same for the Linux/Unix/MacOS/whatever tests.
haz
was created at P'unk Avenue for use in many projects built with Apostrophe, an open-source content management system built on node.js. (You don't need Apostrophe to use haz
.) If you like haz
you should definitely check out apostrophenow.org. Also be sure to visit us on github.
Feel free to open issues on github.