index.js 648 B

12345678910111213141516171819202122232425262728
  1. var through = require('through2');
  2. var File = require('vinyl');
  3. var url = require('url');
  4. var hyperquest = require('hyperquest');
  5. module['exports'] = function dest (glob, opt) {
  6. opt = opt || {};
  7. var _url = url.parse(glob);
  8. var path = _url.protocol + "//" + _url.host + unescape(_url.path);
  9. var remote = hyperquest.post(path);
  10. return through.obj(function(file, enc, cb){
  11. if (file.contents) {
  12. var data = {};
  13. data.path = file.path;
  14. data.contents = file.contents.toString();
  15. remote.write(JSON.stringify(data))
  16. }
  17. cb(null, file);
  18. }, function(cb){
  19. remote.end();
  20. cb();
  21. })
  22. };