You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 692B

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. const execa = require('execa');
  3. const executable = require('executable');
  4. module.exports = (bin, args) => {
  5. if (!Array.isArray(args)) {
  6. args = ['--help'];
  7. }
  8. return executable(bin)
  9. .then(works => {
  10. if (!works) {
  11. throw new Error(`Couldn't execute the \`${bin}\` binary. Make sure it has the right permissions.`);
  12. }
  13. return execa(bin, args);
  14. })
  15. .then(res => res.code === 0);
  16. };
  17. module.exports.sync = (bin, args) => {
  18. if (!Array.isArray(args)) {
  19. args = ['--help'];
  20. }
  21. if (!executable.sync(bin)) {
  22. throw new Error(`Couldn't execute the \`${bin}\` binary. Make sure it has the right permissions.`);
  23. }
  24. return execa.sync(bin, args).status === 0;
  25. };