// Compiled by ClojureScript 1.9.293 {:target :nodejs}
goog.provide('eginez.huckleberry.os');
goog.require('cljs.core');
goog.require('cljs.nodejs');
goog.require('cljs.core.async');
goog.require('clojure.set');
goog.require('clojure.string');
eginez.huckleberry.os.path = cljs.nodejs.require.call(null,"path");
eginez.huckleberry.os.fs = cljs.nodejs.require.call(null,"fs");
eginez.huckleberry.os.xml2js = cljs.nodejs.require.call(null,"xml2js");
eginez.huckleberry.os.request = cljs.nodejs.require.call(null,"request");
eginez.huckleberry.os.HOME_DIR = cljs.nodejs.process.env.HOME;
eginez.huckleberry.os.SEPARATOR = eginez.huckleberry.os.path.sep;
eginez.huckleberry.os.make_http_request = (function eginez$huckleberry$os$make_http_request(cout,url){
eginez.huckleberry.os.request.get(({"url": url, "encoding": null}),(function (error,response,body){
if((cljs.core.not.call(null,error)) && (cljs.core._EQ_.call(null,(200),response.statusCode))){
return cljs.core.async.put_BANG_.call(null,cout,body);
} else {
return null;
}
}));

return cout;
});
eginez.huckleberry.os.read_file = (function eginez$huckleberry$os$read_file(cout,fpath){
eginez.huckleberry.os.fs.readFile(fpath,"utf-8",(function (err,data){
if(cljs.core.truth_(err)){
return null;
} else {
return cljs.core.async.put_BANG_.call(null,cout,data);
}
}));

return cout;
});
eginez.huckleberry.os.create_dir_fully = (function eginez$huckleberry$os$create_dir_fully(dir_path){
if(!(clojure.string.blank_QMARK_.call(null,dir_path))){
try{return eginez.huckleberry.os.fs.mkdirSync([cljs.core.str(dir_path)].join(''));
}catch (e19021){var e = e19021;
eginez.huckleberry.os.create_dir_fully.call(null,eginez.huckleberry.os.path.dirname(dir_path));

return eginez.huckleberry.os.fs.mkdirSync([cljs.core.str(dir_path)].join(''));
}} else {
return null;
}
});
eginez.huckleberry.os.create_conditionally = (function eginez$huckleberry$os$create_conditionally(dir_path){
try{return eginez.huckleberry.os.fs.statSync(dir_path);
}catch (e19032){var e = e19032;
return eginez.huckleberry.os.create_dir_fully.call(null,dir_path);
}});
eginez.huckleberry.os.write_file = (function eginez$huckleberry$os$write_file(file_path,content){
eginez.huckleberry.os.create_conditionally.call(null,eginez.huckleberry.os.path.dirname(file_path));

eginez.huckleberry.os.fs.writeFileSync(file_path,content);

return true;
});
eginez.huckleberry.os.parse_xml = (function eginez$huckleberry$os$parse_xml(xmlstring){

var x = cljs.core.async.chan.call(null);
eginez.huckleberry.os.xml2js.parseString(xmlstring,((function (x){
return (function (p1__19046_SHARP_,p2__19045_SHARP_){
return cljs.core.async.put_BANG_.call(null,x,p2__19045_SHARP_);
});})(x))
);

return cljs.core.async.poll_BANG_.call(null,x);
});
