Beispiel #1
0
 return T.makeTask(cb => {
   rs.pipe(ws, opts);
   const doEnd = (!opts || opts.end !== false) && (ws as any) !== process.stdout && (ws as any) !== process.stderr;
   const state: PipeState = {
     onError: null,
     onSuccess: null,
     resolved: false
   };
   if (doEnd) {
     state.onError = onErrorWS.bind(null, state, ws, cb);
     state.onSuccess = onSuccessWS.bind(null, state, ws, cb);
     ws.once('error', state.onError as any);
     ws.once('finish', state.onSuccess as any);
     return T.thunkCanceller(() => cleanUpListenerWS(state, ws));
   }
   // we not use automatic finish, so attach to readable
   state.onError = onErrorRS.bind(null, state, rs, cb);
   state.onSuccess = onSuccessRS.bind(null, state, rs, cb);
   rs.once('error', state.onError as any);
   rs.once('end', state.onSuccess as any);
   return T.thunkCanceller(() => cleanUpListenerRS(state, rs));
 });
Beispiel #2
0
 return T.makeTask(cb => {
   process.once(signal as any, cb as any);
   return T.thunkCanceller(() => {
     process.removeListener(signal, cb as any);
   });
 });