UNPKG

@atomist/clj-editors

Version:

editor functions that use rewrite-clj and other important things from the clojurescript ecosystem

456 lines (391 loc) 16.1 kB
// Compiled by ClojureScript 1.10.238 {:target :nodejs} goog.provide('cljs_node_io.proc'); goog.require('cljs.core'); goog.require('cljs.core.async'); goog.require('cljs.core.async.impl.protocols'); goog.require('cljs_node_io.async'); goog.require('cljs_node_io.protocols'); goog.require('clojure.string'); cljs_node_io.proc.childproc = require("child_process"); /** * @return {(buffer.Buffer|String)} */ cljs_node_io.proc.exec = (function cljs_node_io$proc$exec(var_args){ var G__22484 = arguments.length; switch (G__22484) { case 1: return cljs_node_io.proc.exec.cljs$core$IFn$_invoke$arity$1((arguments[(0)])); break; case 2: return cljs_node_io.proc.exec.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)])); break; default: throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join(''))); } }); cljs_node_io.proc.exec.cljs$core$IFn$_invoke$arity$1 = (function (cmdstr){ return cljs_node_io.proc.exec.call(null,cmdstr,null); }); cljs_node_io.proc.exec.cljs$core$IFn$_invoke$arity$2 = (function (cmdstr,opts){ return cljs_node_io.proc.childproc.execSync.call(null,cmdstr,cljs.core.clj__GT_js.call(null,opts)); }); cljs_node_io.proc.exec.cljs$lang$maxFixedArity = 2; /** * @return {!impl/Channel} <= [Error {string|Buffer} {string|Buffer}] */ cljs_node_io.proc.aexec = (function cljs_node_io$proc$aexec(var_args){ var G__22487 = arguments.length; switch (G__22487) { case 1: return cljs_node_io.proc.aexec.cljs$core$IFn$_invoke$arity$1((arguments[(0)])); break; case 2: return cljs_node_io.proc.aexec.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)])); break; default: throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join(''))); } }); cljs_node_io.proc.aexec.cljs$core$IFn$_invoke$arity$1 = (function (cmdstr){ return cljs_node_io.proc.aexec.call(null,cmdstr,null); }); cljs_node_io.proc.aexec.cljs$core$IFn$_invoke$arity$2 = (function (cmdstr,opts){ var out = cljs.core.async.promise_chan.call(null); var cb = ((function (out){ return (function (err,stdout,stderr){ return cljs.core.async.put_BANG_.call(null,out,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [err,stdout,stderr], null)); });})(out)) ; cljs_node_io.proc.childproc.exec.call(null,cmdstr,cljs.core.clj__GT_js.call(null,opts),cb); return out; }); cljs_node_io.proc.aexec.cljs$lang$maxFixedArity = 2; /** * @param {!string} pathstr :: the file to execute * @param {!IVector} args :: args to the executable * @param {!IMap} opts :: execution options * @return {(buffer.Buffer|String)} */ cljs_node_io.proc.execFile = (function cljs_node_io$proc$execFile(pathstr,args,opts){ return cljs_node_io.proc.childproc.execFileSync.call(null,pathstr,cljs.core.into_array.call(null,args),cljs.core.clj__GT_js.call(null,opts)); }); /** * @param {!string} pathstr :: the file to execute * @param {!IVector} args :: args to the executable * @param {!IMap} opts :: execution options * @return {!impl/Channel} <= [Error {string|Buffer} {string|Buffer}] */ cljs_node_io.proc.aexecFile = (function cljs_node_io$proc$aexecFile(pathstr,args,opts){ var out = cljs.core.async.promise_chan.call(null); var cb = ((function (out){ return (function (err,stdout,stderr){ return cljs.core.async.put_BANG_.call(null,out,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [err,stdout,stderr], null)); });})(out)) ; cljs_node_io.proc.childproc.execFile.call(null,pathstr,cljs.core.into_array.call(null,args),cljs.core.clj__GT_js.call(null,opts),cb); return out; }); /** * @param {!string} cmd :: command to execute in a shell * @param {!IVector} args :: args to the shell command * @param {!IMap} opts :: execution options * @return {!child_process.ChildProcess} */ cljs_node_io.proc.spawn = (function cljs_node_io$proc$spawn(cmd,args,opts){ var opts__$1 = (cljs.core.truth_(opts)?cljs.core.clj__GT_js.call(null,opts):({})); var proc = cljs_node_io.proc.childproc.spawn.call(null,cmd,cljs.core.into_array.call(null,args),opts__$1); return proc; }); /** * An exception to the 'a' prefix rule: cp.spawnSync will block until its * process exits before returning a modified ChildProcess object. This is * significantly less useful than a persisting asynchronous spawn * @param {!string} cmd :: command to execute in a shell * @param {!IVector} args :: args to the shell command * @param {!IMap} opts :: map of execution options * @return {!Object} */ cljs_node_io.proc.spawn_sync = (function cljs_node_io$proc$spawn_sync(cmd,args,opts){ var opts__$1 = (cljs.core.truth_(opts)?cljs.core.clj__GT_js.call(null,opts):({})); var proc = cljs_node_io.proc.childproc.spawnSync.call(null,cmd,cljs.core.into_array.call(null,args),opts__$1); return proc; }); /** * @param {!string} modulePath :: path to js file to run * @param {!IVector} args :: arguments to the js file * @param {!IMap} opts :: map of execution options * @return {!child_process.ChildProcess} */ cljs_node_io.proc.fork = (function cljs_node_io$proc$fork(modulePath,args,opts){ var args__$1 = cljs.core.apply.call(null,cljs.core.array,args); var opts__$1 = cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"silent","silent",-1142977785),true,new cljs.core.Keyword(null,"stdio","stdio",-1570777132),"pipe"], null),opts); var ps = cljs_node_io.proc.childproc.fork.call(null,modulePath,args__$1,cljs.core.clj__GT_js.call(null,opts__$1)); ps.stdout.setEncoding("utf8"); ps.stderr.setEncoding("utf8"); return ps; }); /** * @return {!impl/Channel} <= [?err] */ cljs_node_io.proc.cp_send = (function cljs_node_io$proc$cp_send(var_args){ var G__22490 = arguments.length; switch (G__22490) { case 2: return cljs_node_io.proc.cp_send.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)])); break; case 3: return cljs_node_io.proc.cp_send.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)])); break; case 4: return cljs_node_io.proc.cp_send.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)])); break; default: throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join(''))); } }); cljs_node_io.proc.cp_send.cljs$core$IFn$_invoke$arity$2 = (function (CP,msg){ return cljs_node_io.proc.cp_send.call(null,CP,msg,null); }); cljs_node_io.proc.cp_send.cljs$core$IFn$_invoke$arity$3 = (function (CP,msg,handle){ return cljs_node_io.proc.cp_send.call(null,CP,msg,null,null); }); cljs_node_io.proc.cp_send.cljs$core$IFn$_invoke$arity$4 = (function (CP,msg,handle,opts){ if(cljs.core.truth_(CP.proc.send)){ } else { throw (new Error(["Assert failed: ","ChildProcess.send is only applicable to forks","\n","(.-send (.-proc CP))"].join(''))); } var out = cljs.core.async.promise_chan.call(null); var cb = ((function (out){ return (function (err){ return cljs.core.async.put_BANG_.call(null,out,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [err], null)); });})(out)) ; var args = cljs.core.remove.call(null,cljs.core.nil_QMARK_,new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.clj__GT_js.call(null,msg),handle,opts,cb], null)); CP.proc.send.apply(CP.proc,cljs.core.into_array.call(null,args)); return out; }); cljs_node_io.proc.cp_send.cljs$lang$maxFixedArity = 4; /** * Defers to stdin.write, but skips writing when the stream has closed, returning * false (instead of emitting error to already closed channel) * * Calls the supplied callback once the data has been fully handled. * If an error occurs, the callback may or may not be called with the error as its first argument. * To reliably detect write errors, add a listener for the 'error' event. * * The return value indicates whether the written chunk was buffered internally and * the buffer has exceeded the highWaterMark configured when the stream was created. * If false is returned, further attempts to write data to the stream should be paused * until the 'drain' event is emitted. * @return {!boolean} */ cljs_node_io.proc.cp_write = (function cljs_node_io$proc$cp_write(var_args){ var G__22493 = arguments.length; switch (G__22493) { case 2: return cljs_node_io.proc.cp_write.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)])); break; case 3: return cljs_node_io.proc.cp_write.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)])); break; case 4: return cljs_node_io.proc.cp_write.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)])); break; default: throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join(''))); } }); cljs_node_io.proc.cp_write.cljs$core$IFn$_invoke$arity$2 = (function (cp,chunk){ return cljs_node_io.proc.cp_write.call(null,chunk,null,null); }); cljs_node_io.proc.cp_write.cljs$core$IFn$_invoke$arity$3 = (function (cp,chunk,enc){ return cljs_node_io.proc.cp_write.call(null,chunk,enc,null); }); cljs_node_io.proc.cp_write.cljs$core$IFn$_invoke$arity$4 = (function (cp,chunk,enc,cb){ if(cp.proc.stdin.writable){ return cp.proc.stdin.write(chunk,enc,cb); } else { return false; } }); cljs_node_io.proc.cp_write.cljs$lang$maxFixedArity = 4; /** * @constructor * @implements {cljs_node_io.protocols.IChildProcess} * @implements {cljs.core.async.impl.protocols.ReadPort} * @implements {cljs_node_io.proc.Object} * @implements {cljs.core.ILookup} */ cljs_node_io.proc.ChildProcess = (function (proc,out){ this.proc = proc; this.out = out; this.cljs$lang$protocol_mask$partition0$ = 256; this.cljs$lang$protocol_mask$partition1$ = 0; }); cljs_node_io.proc.ChildProcess.prototype.cljs_node_io$protocols$IChildProcess$ = cljs.core.PROTOCOL_SENTINEL; cljs_node_io.proc.ChildProcess.prototype.cljs$core$ILookup$_lookup$arity$2 = (function (this$,k){ var self__ = this; var this$__$1 = this; return cljs.core.get.call(null,this$__$1.props(),k); }); cljs_node_io.proc.ChildProcess.prototype.cljs$core$async$impl$protocols$ReadPort$ = cljs.core.PROTOCOL_SENTINEL; cljs_node_io.proc.ChildProcess.prototype.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2 = (function (_,handler){ var self__ = this; var ___$1 = this; return cljs.core.async.impl.protocols.take_BANG_.call(null,self__.out,handler); }); cljs_node_io.proc.ChildProcess.prototype.setEncoding = (function (enc){ var self__ = this; var this$ = this; self__.proc.stdout.setEncoding(enc); self__.proc.stderr.setEncoding(enc); return this$; }); cljs_node_io.proc.ChildProcess.prototype.kill = (function() { var G__22495 = null; var G__22495__0 = (function (){ var self__ = this; var _ = this; return self__.proc.kill(); }); var G__22495__1 = (function (sig){ var self__ = this; var _ = this; return self__.proc.kill(sig); }); G__22495 = function(sig){ switch(arguments.length){ case 0: return G__22495__0.call(this); case 1: return G__22495__1.call(this,sig); } throw(new Error('Invalid arity: ' + (arguments.length - 1))); }; G__22495.cljs$core$IFn$_invoke$arity$0 = G__22495__0; G__22495.cljs$core$IFn$_invoke$arity$1 = G__22495__1; return G__22495; })() ; cljs_node_io.proc.ChildProcess.prototype.disconnect = (function (){ var self__ = this; var _ = this; return self__.proc.disconnect(); }); cljs_node_io.proc.ChildProcess.prototype.write = (function() { var G__22496 = null; var G__22496__1 = (function (chunk){ var self__ = this; var this$ = this; return cljs_node_io.proc.cp_write.call(null,this$,chunk); }); var G__22496__2 = (function (chunk,enc){ var self__ = this; var this$ = this; return cljs_node_io.proc.cp_write.call(null,this$,chunk,enc); }); var G__22496__3 = (function (chunk,enc,cb){ var self__ = this; var this$ = this; return cljs_node_io.proc.cp_write.call(null,this$,chunk,enc,cb); }); G__22496 = function(chunk,enc,cb){ switch(arguments.length){ case 1: return G__22496__1.call(this,chunk); case 2: return G__22496__2.call(this,chunk,enc); case 3: return G__22496__3.call(this,chunk,enc,cb); } throw(new Error('Invalid arity: ' + (arguments.length - 1))); }; G__22496.cljs$core$IFn$_invoke$arity$1 = G__22496__1; G__22496.cljs$core$IFn$_invoke$arity$2 = G__22496__2; G__22496.cljs$core$IFn$_invoke$arity$3 = G__22496__3; return G__22496; })() ; cljs_node_io.proc.ChildProcess.prototype.send = (function() { var G__22497 = null; var G__22497__1 = (function (msg){ var self__ = this; var this$ = this; return cljs_node_io.proc.cp_send.call(null,this$,msg); }); var G__22497__2 = (function (msg,handle){ var self__ = this; var this$ = this; return cljs_node_io.proc.cp_send.call(null,this$,msg,handle); }); var G__22497__3 = (function (msg,handle,opts){ var self__ = this; var this$ = this; return cljs_node_io.proc.cp_send.call(null,this$,msg,handle,opts); }); G__22497 = function(msg,handle,opts){ switch(arguments.length){ case 1: return G__22497__1.call(this,msg); case 2: return G__22497__2.call(this,msg,handle); case 3: return G__22497__3.call(this,msg,handle,opts); } throw(new Error('Invalid arity: ' + (arguments.length - 1))); }; G__22497.cljs$core$IFn$_invoke$arity$1 = G__22497__1; G__22497.cljs$core$IFn$_invoke$arity$2 = G__22497__2; G__22497.cljs$core$IFn$_invoke$arity$3 = G__22497__3; return G__22497; })() ; cljs_node_io.proc.ChildProcess.prototype.props = (function (){ var self__ = this; var this$ = this; return new cljs.core.PersistentArrayMap(null, 6, [new cljs.core.Keyword(null,"connected","connected",-169833045),self__.proc.connected,new cljs.core.Keyword(null,"stdout","stdout",-531490018),self__.proc.stdout,new cljs.core.Keyword(null,"stdin","stdin",177433088),self__.proc.stdin,new cljs.core.Keyword(null,"stderr","stderr",-1571650309),self__.proc.stderr,new cljs.core.Keyword(null,"stdio","stdio",-1570777132),self__.proc.stdio,new cljs.core.Keyword(null,"pid","pid",1018387698),self__.proc.pid], null); }); cljs_node_io.proc.ChildProcess.getBasis = (function (){ return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"proc","proc",-643106804,null),new cljs.core.Symbol(null,"out","out",729986010,null)], null); }); cljs_node_io.proc.ChildProcess.cljs$lang$type = true; cljs_node_io.proc.ChildProcess.cljs$lang$ctorStr = "cljs-node-io.proc/ChildProcess"; cljs_node_io.proc.ChildProcess.cljs$lang$ctorPrWriter = (function (this__4161__auto__,writer__4162__auto__,opt__4163__auto__){ return cljs.core._write.call(null,writer__4162__auto__,"cljs-node-io.proc/ChildProcess"); }); /** * Positional factory function for cljs-node-io.proc/ChildProcess. */ cljs_node_io.proc.__GT_ChildProcess = (function cljs_node_io$proc$__GT_ChildProcess(proc,out){ return (new cljs_node_io.proc.ChildProcess(proc,out)); }); /** * Given a node childproces instance, returns a IChildProcess * with a ReadPort implementation. Opts include: * :buf-or-n -> passed to all subchannels, defaults to 10 * :key -> is used to prefix all emmited values. Use to identify and route data. * ex no key: [:stdout [:data ['some data']]] * ex w/ key: ['my-child-proc' [:stdout [:data ['some data']]]] */ cljs_node_io.proc.child = (function cljs_node_io$proc$child(var_args){ var G__22499 = arguments.length; switch (G__22499) { case 1: return cljs_node_io.proc.child.cljs$core$IFn$_invoke$arity$1((arguments[(0)])); break; case 2: return cljs_node_io.proc.child.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)])); break; default: throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join(''))); } }); cljs_node_io.proc.child.cljs$core$IFn$_invoke$arity$1 = (function (proc){ return cljs_node_io.proc.child.call(null,proc,null); }); cljs_node_io.proc.child.cljs$core$IFn$_invoke$arity$2 = (function (proc,opts){ var out = cljs_node_io.async.cp__GT_ch.call(null,proc,opts); return cljs_node_io.proc.__GT_ChildProcess.call(null,proc,out); }); cljs_node_io.proc.child.cljs$lang$maxFixedArity = 2; //# sourceMappingURL=proc.js.map