stash.js 681 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. var log = require('fancy-log');
  3. var exec = require('child_process').exec;
  4. module.exports = function(opt, cb) {
  5. if (!cb && typeof opt === 'function') {
  6. // optional options
  7. cb = opt;
  8. opt = {};
  9. }
  10. if (!cb || typeof cb !== 'function') cb = function () {};
  11. if (!opt) opt = {};
  12. if (!opt.args) opt.args = 'save --include-untracked "gulp-stash"';
  13. if (!opt.cwd) opt.cwd = process.cwd();
  14. var maxBuffer = opt.maxBuffer || 200 * 1024;
  15. var cmd = 'git stash ' + opt.args;
  16. exec(cmd, {cwd: opt.cwd, maxBuffer: maxBuffer}, function(err, stdout, stderr) {
  17. if (err) return cb(err);
  18. if (!opt.quiet) log(stdout, stderr);
  19. cb(null);
  20. });
  21. };