tools.js 456 B

12345678910111213141516171819202122232425
  1. /* global module */
  2. /* global require */
  3. 'use strict';
  4. module.exports = {
  5. getGitDirtyFiles: function() {
  6. return this.shExec( 'git diff-index --name-only HEAD' ).split( '\n' );
  7. },
  8. shExec: function( command ) {
  9. var sh = require( 'shelljs' );
  10. sh.config.silent = true;
  11. var ret = sh.exec( command );
  12. if ( ret.code ) {
  13. throw new Error(
  14. 'Error while executing `' + command + '`:\n\n' +
  15. ret.output
  16. );
  17. }
  18. return ret.output;
  19. }
  20. };