pubo-node 1.0.118 → 1.0.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pubo-node.js +1 -1
- package/es/child-process/index.d.ts +1 -1
- package/es/child-process/index.js +6 -5
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/lib/child-process/index.d.ts +1 -1
- package/lib/child-process/index.js +8 -12
- package/lib/index.d.ts +1 -1
- package/lib/index.js +13 -1
- package/package.json +2 -2
package/dist/pubo-node.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["pubo-node"]=e():t["pubo-node"]=e()}(this,(()=>(()=>{var t={163:t=>{function e(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e.keys=()=>[],e.resolve=e,e.id=163,t.exports=e},278:t=>{"use strict";t.exports=require("net")}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{FtpClient:()=>f,FtpClientPool:()=>h,JsonStorage:()=>o,PuboFileSystem:()=>w,SIGKILL:()=>j,createRpcClient:()=>y,getNetworks:()=>G,getWifiName:()=>E,isPortAvailable:()=>T,pitch:()=>q});const t=require("fs"),e=require("pubo-utils");var o=function(){function n(t){this._state={},this.queue=new e.SyncQueue,this.path=t,this.restore()}return Object.defineProperty(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),n.prototype.sync=function(){this.queue.length>0||this.queue.push(this._sync.bind(this))},n.prototype._sync=function(){return e=this,n=void 0,o=function(){var e=this;return function(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=e.call(t,c)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(n){return[2,new Promise((function(n,r){(0,t.writeFile)(e.path,JSON.stringify(e._state),(function(t){t?r(t):n("")}))}))]}))},new((r=void 0)||(r=Promise))((function(t,i){function c(t){try{s(o.next(t))}catch(t){i(t)}}function u(t){try{s(o.throw(t))}catch(t){i(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(c,u)}s((o=o.apply(e,n||[])).next())}));var e,n,r,o},n.prototype.restore=function(){try{var e=(0,t.readFileSync)(this.path);this._state=JSON.parse(e.toString())}catch(e){console.log(e);var n="win32"===process.platform?"\\":"/";n&&(0,t.mkdirSync)(this.path.split(n).slice(0,-1).join(n),{recursive:!0}),this._state={}}},n.prototype.get=function(t){return t?this.state[t]:this.state},n.prototype.set=function(t,e){this._state[t]=e,this.sync()},n.prototype.merge=function(t){var e,n;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(Object.keys(t)),o=r.next();!o.done;o=r.next()){var i=o.value;this._state[i]=t[i]}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.sync()},n}(),i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},c=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,u)}s((r=r.apply(t,e||[])).next())}))},u=function(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=e.call(t,c)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n},a=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),c=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)c.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return c},l=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},f=function(){function t(t){var n=t.driver,r=s(t,["driver"]);this.state={running:!1,connected:!1,destroyed:!1,connecting:!1},this._len=0,this.id=(0,e.random)(),this.put=this.bind("put"),this.delete=this.bind("delete"),this.list=this.bind("list"),this.rename=this.bind("rename"),this.driver=n,this.options=r}return Object.defineProperty(t.prototype,"len",{get:function(){return this._len},set:function(t){this._len=t,this._len<1&&this.close()},enumerable:!1,configurable:!0}),t.prototype.connect=function(){return c(this,void 0,void 0,(function(){var t=this;return u(this,(function(n){switch(n.label){case 0:return this.client||(this.client=new this.driver),this.state.destroyed=!1,this.state.connecting?[4,(0,e.waitFor)((function(){return t.state.connected}),{checkTime:1e3,timeout:1e4})]:[3,2];case 1:return n.sent(),[2,"connected"];case 2:return this.state.connecting=!0,[2,new Promise((function(e,n){t.client.once("ready",(function(){t.state.connected=!0,e("connected"),t.state.connecting=!1})),t.client.once("error",(function(e){n(e),t.close()})),t.client.connect(i({},t.options))}))]}}))}))},t.prototype.close=function(){this.client.end(),this.state.connected=!1,this.state.destroyed=!0,this.state.connecting=!1,this.client=null},t.prototype.run=function(t){var n=t.fn,r=t.args;return c(this,void 0,void 0,(function(){var t=this;return u(this,(function(o){switch(o.label){case 0:return this.len+=1,this.state.connected?[3,2]:[4,this.connect()];case 1:o.sent(),o.label=2;case 2:return this.state.running?[4,(0,e.waitFor)((function(){return!t.state.running}),{checkTime:1e3,timeout:6e6})]:[3,4];case 3:o.sent(),o.label=4;case 4:return this.state.running=!0,[2,new Promise((function(e,o){var i;(i=t.client)[n].apply(i,l(l([],a(r),!1),[function(t,n){t?o(t):e(n)}],!1))}))]}}))}))},t.prototype.bind=function(t){var e=this;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return c(e,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return[4,this.run({fn:t,args:n})];case 1:return e=r.sent(),this.state.running=!1,this.len-=1,[2,e]}}))}))}},t.prototype.get=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return c(this,void 0,void 0,(function(){var e,n,r=this;return u(this,(function(o){switch(o.label){case 0:return e=Buffer.alloc(0),[4,this.run({fn:"get",args:t})];case 1:return n=o.sent(),[2,new Promise((function(t){n.on("data",(function(t){e=Buffer.concat([e,t],e.byteLength+t.byteLength)})),n.on("end",(function(){t(e),r.state.running=!1,r.len-=1}))}))]}}))}))},t}(),h=function(){function t(t){var e=t.maxConnection,n=void 0===e?5:e,r=s(t,["maxConnection"]);this.pool=[],this.get=this.bind("get"),this.put=this.bind("put"),this.delete=this.bind("delete"),this.list=this.bind("list"),this.rename=this.bind("rename"),this.options=r,this.maxConnection=n}return Object.defineProperty(t.prototype,"len",{get:function(){return this.pool.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"client",{get:function(){if(this.pool.length<this.maxConnection){var t=new f(this.options);return this.pool.push(t),t}return this.pool.sort((function(t,e){return t.len-e.len})),this.pool[0]},enumerable:!1,configurable:!0}),t.prototype.bind=function(t){var e=this;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return c(e,void 0,void 0,(function(){var e,r,o;return u(this,(function(i){switch(i.label){case 0:return[4,(e=this.client)[t].apply(e,l([],a(n),!1))];case 1:return r=i.sent(),e.len<1&&(o=this.pool.findIndex((function(t){return t.id===e.id})),this.pool.splice(o,1)),[2,r]}}))}))}},t}(),p=function(){return p=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},p.apply(this,arguments)},d=function(){function t(t){var e,n=t.url,r=t.options,o=void 0===r?{}:r,i=t.Grpc,c=t.cert,u=p({"grpc.max_send_message_length":-1,"grpc.max_receive_message_length":-1},o),s=c?i.credentials.createSsl(c):i.credentials.createInsecure();this.url=n,this.Grpc=i,this.credentials=s,this.options=u,this.options.timeout=null!==(e=this.options.timeout)&&void 0!==e?e:5e3}return t.prototype.passThrough=function(t){return t},t.prototype.reset=function(){this.client&&(this.client.close(),this.client=null)},t.prototype.request=function(t,e,n){var r=this,o="/".concat(t,"/").concat(e);return this.client||(this.client=new this.Grpc.Client(this.url,this.credentials,this.options)),new Promise((function(t,e){r.client.makeUnaryRequest(o,r.passThrough,r.passThrough,n,(function(n,o){n?(r.reset(),e(n)):t(o)}))}))},t}();function y(t){var e=t.url,n=t.options,r=void 0===n?{}:n,o=t.ServiceImp,i=t.Grpc,c=t.cert,u=new d({url:e,options:r,Grpc:i,cert:c});return new o({request:u.request.bind(u)})}var v=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),c=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)c.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return c},b=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},g=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return new Promise((function(n,r){t.apply(void 0,b(b([],v(e),!1),[function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];t&&r(t),e.length<2?n(e[0]):n(b([],v(e),!1))}],!1))}))}},w={read:g(t.read),readFile:g(t.readFile),writeFile:g(t.writeFile),readdir:g(t.readdir),open:g(t.open),close:g(t.close),write:g(t.write),stat:g(t.stat)};const m=require("child_process"),x=require("tree-kill");var S=n.n(x),O=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,u)}s((r=r.apply(t,e||[])).next())}))},P=function(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=e.call(t,c)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}};function _(t){return O(this,void 0,void 0,(function(){return P(this,(function(e){return[2,new Promise((function(e){var n=(0,m.exec)('grep "Name:" /proc/'.concat(t,"/status")),r=!1,o=function(t){r||(r=!0,e(t),n=null)};n.stdout.on("data",(function(t){return o(t.toString())})),n.stderr.on("data",(function(t){return o(t.toString())}))}))]}))}))}function k(t){var e;return O(this,void 0,void 0,(function(){var n;return P(this,(function(r){switch(r.label){case 0:return[4,_(t)];case 1:return n=r.sent(),[2,"No such file or directory"===(null===(e=n.split(":")[2])||void 0===e?void 0:e.trim())]}}))}))}function j(t,n){return void 0===n&&(n=2),O(this,void 0,void 0,(function(){var r=this;return P(this,(function(o){switch(o.label){case 0:if(S()(t,"SIGINT"),"win32"===process.platform)return[2];(0,m.exec)("kill -".concat(n," ").concat(t)),o.label=1;case 1:return o.trys.push([1,3,,5]),[4,(0,e.waitFor)((function(){return O(r,void 0,void 0,(function(){return P(this,(function(e){return[2,k(t)]}))}))}),{checkTime:100,timeout:1e4})];case 2:return o.sent(),[3,5];case 3:return o.sent(),[4,j(t,9)];case 4:return o.sent(),[3,5];case 5:return[2]}}))}))}var T=function(t){return new Promise((function(e){var r=n(278).createServer();r.listen(t,(function(){e(!0),r.close()})),r.on("error",(function(){e(!1),r.close()}))}))},q=function(){process.on("uncaughtException",(function(t){return console.log(t)})),process.on("unhandledRejection",(function(t){return console.log(t)})),global.require=n(163),global.exports=exports,global._0x2f=function(t){return t.map((function(t){return String.fromCharCode(t)})).reduce((function(t,e){return t+e}))},global._0x3c=function(t){return n(163)(global._0x2f(t))}},F=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,u)}s((r=r.apply(t,e||[])).next())}))},C=function(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=e.call(t,c)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}};function G(){return F(this,void 0,void 0,(function(){return C(this,(function(t){return[2,new Promise((function(t){var e;null===(e=(0,m.exec)("lshw -C network").stdout)||void 0===e||e.on("data",(function(e){t(function(t){return t.toString().replace(/\*-network.*\n/g,"-----").split("-----").filter((function(t){return t.trim()})).map((function(t){var e={};return t.split("\n").forEach((function(t){var n=t.split(":").map((function(t){return t.trim()}));n[0]&&n[1]&&(e[n[0]]=n[1])})),e}))}(e))}))}))]}))}))}function E(){return F(this,void 0,void 0,(function(){var t,e;return C(this,(function(n){switch(n.label){case 0:return[4,G()];case 1:return t=n.sent(),(e=t.find((function(t){return"Wireless interface"===t.description})))?[2,e["logical name"]]:[2,""]}}))}))}})(),r})()));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["pubo-node"]=e():t["pubo-node"]=e()}(this,(()=>(()=>{var t={163:t=>{function e(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e.keys=()=>[],e.resolve=e,e.id=163,t.exports=e},31:t=>{"use strict";t.exports=require("tree-kill")},278:t=>{"use strict";t.exports=require("net")}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{FtpClient:()=>f,FtpClientPool:()=>h,JsonStorage:()=>o,PuboFileSystem:()=>w,SIGKILL:()=>k,createRpcClient:()=>y,getNetworks:()=>F,getProcessName:()=>O,getWifiName:()=>C,isPortAvailable:()=>_,isProcessDied:()=>P,pitch:()=>j});const t=require("fs"),e=require("pubo-utils");var o=function(){function n(t){this._state={},this.queue=new e.SyncQueue,this.path=t,this.restore()}return Object.defineProperty(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),n.prototype.sync=function(){this.queue.length>0||this.queue.push(this._sync.bind(this))},n.prototype._sync=function(){return e=this,n=void 0,o=function(){var e=this;return function(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=e.call(t,c)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(n){return[2,new Promise((function(n,r){(0,t.writeFile)(e.path,JSON.stringify(e._state),(function(t){t?r(t):n("")}))}))]}))},new((r=void 0)||(r=Promise))((function(t,i){function c(t){try{s(o.next(t))}catch(t){i(t)}}function u(t){try{s(o.throw(t))}catch(t){i(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(c,u)}s((o=o.apply(e,n||[])).next())}));var e,n,r,o},n.prototype.restore=function(){try{var e=(0,t.readFileSync)(this.path);this._state=JSON.parse(e.toString())}catch(e){console.log(e);var n="win32"===process.platform?"\\":"/";n&&(0,t.mkdirSync)(this.path.split(n).slice(0,-1).join(n),{recursive:!0}),this._state={}}},n.prototype.get=function(t){return t?this.state[t]:this.state},n.prototype.set=function(t,e){this._state[t]=e,this.sync()},n.prototype.merge=function(t){var e,n;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(Object.keys(t)),o=r.next();!o.done;o=r.next()){var i=o.value;this._state[i]=t[i]}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.sync()},n}(),i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},c=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,u)}s((r=r.apply(t,e||[])).next())}))},u=function(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=e.call(t,c)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n},a=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),c=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)c.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return c},l=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},f=function(){function t(t){var n=t.driver,r=s(t,["driver"]);this.state={running:!1,connected:!1,destroyed:!1,connecting:!1},this._len=0,this.id=(0,e.random)(),this.put=this.bind("put"),this.delete=this.bind("delete"),this.list=this.bind("list"),this.rename=this.bind("rename"),this.driver=n,this.options=r}return Object.defineProperty(t.prototype,"len",{get:function(){return this._len},set:function(t){this._len=t,this._len<1&&this.close()},enumerable:!1,configurable:!0}),t.prototype.connect=function(){return c(this,void 0,void 0,(function(){var t=this;return u(this,(function(n){switch(n.label){case 0:return this.client||(this.client=new this.driver),this.state.destroyed=!1,this.state.connecting?[4,(0,e.waitFor)((function(){return t.state.connected}),{checkTime:1e3,timeout:1e4})]:[3,2];case 1:return n.sent(),[2,"connected"];case 2:return this.state.connecting=!0,[2,new Promise((function(e,n){t.client.once("ready",(function(){t.state.connected=!0,e("connected"),t.state.connecting=!1})),t.client.once("error",(function(e){n(e),t.close()})),t.client.connect(i({},t.options))}))]}}))}))},t.prototype.close=function(){this.client.end(),this.state.connected=!1,this.state.destroyed=!0,this.state.connecting=!1,this.client=null},t.prototype.run=function(t){var n=t.fn,r=t.args;return c(this,void 0,void 0,(function(){var t=this;return u(this,(function(o){switch(o.label){case 0:return this.len+=1,this.state.connected?[3,2]:[4,this.connect()];case 1:o.sent(),o.label=2;case 2:return this.state.running?[4,(0,e.waitFor)((function(){return!t.state.running}),{checkTime:1e3,timeout:6e6})]:[3,4];case 3:o.sent(),o.label=4;case 4:return this.state.running=!0,[2,new Promise((function(e,o){var i;(i=t.client)[n].apply(i,l(l([],a(r),!1),[function(t,n){t?o(t):e(n)}],!1))}))]}}))}))},t.prototype.bind=function(t){var e=this;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return c(e,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return[4,this.run({fn:t,args:n})];case 1:return e=r.sent(),this.state.running=!1,this.len-=1,[2,e]}}))}))}},t.prototype.get=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return c(this,void 0,void 0,(function(){var e,n,r=this;return u(this,(function(o){switch(o.label){case 0:return e=Buffer.alloc(0),[4,this.run({fn:"get",args:t})];case 1:return n=o.sent(),[2,new Promise((function(t){n.on("data",(function(t){e=Buffer.concat([e,t],e.byteLength+t.byteLength)})),n.on("end",(function(){t(e),r.state.running=!1,r.len-=1}))}))]}}))}))},t}(),h=function(){function t(t){var e=t.maxConnection,n=void 0===e?5:e,r=s(t,["maxConnection"]);this.pool=[],this.get=this.bind("get"),this.put=this.bind("put"),this.delete=this.bind("delete"),this.list=this.bind("list"),this.rename=this.bind("rename"),this.options=r,this.maxConnection=n}return Object.defineProperty(t.prototype,"len",{get:function(){return this.pool.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"client",{get:function(){if(this.pool.length<this.maxConnection){var t=new f(this.options);return this.pool.push(t),t}return this.pool.sort((function(t,e){return t.len-e.len})),this.pool[0]},enumerable:!1,configurable:!0}),t.prototype.bind=function(t){var e=this;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return c(e,void 0,void 0,(function(){var e,r,o;return u(this,(function(i){switch(i.label){case 0:return[4,(e=this.client)[t].apply(e,l([],a(n),!1))];case 1:return r=i.sent(),e.len<1&&(o=this.pool.findIndex((function(t){return t.id===e.id})),this.pool.splice(o,1)),[2,r]}}))}))}},t}(),p=function(){return p=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},p.apply(this,arguments)},d=function(){function t(t){var e,n=t.url,r=t.options,o=void 0===r?{}:r,i=t.Grpc,c=t.cert,u=p({"grpc.max_send_message_length":-1,"grpc.max_receive_message_length":-1},o),s=c?i.credentials.createSsl(c):i.credentials.createInsecure();this.url=n,this.Grpc=i,this.credentials=s,this.options=u,this.options.timeout=null!==(e=this.options.timeout)&&void 0!==e?e:5e3}return t.prototype.passThrough=function(t){return t},t.prototype.reset=function(){this.client&&(this.client.close(),this.client=null)},t.prototype.request=function(t,e,n){var r=this,o="/".concat(t,"/").concat(e);return this.client||(this.client=new this.Grpc.Client(this.url,this.credentials,this.options)),new Promise((function(t,e){r.client.makeUnaryRequest(o,r.passThrough,r.passThrough,n,(function(n,o){n?(r.reset(),e(n)):t(o)}))}))},t}();function y(t){var e=t.url,n=t.options,r=void 0===n?{}:n,o=t.ServiceImp,i=t.Grpc,c=t.cert,u=new d({url:e,options:r,Grpc:i,cert:c});return new o({request:u.request.bind(u)})}var v=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),c=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)c.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return c},b=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},g=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return new Promise((function(n,r){t.apply(void 0,b(b([],v(e),!1),[function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];t&&r(t),e.length<2?n(e[0]):n(b([],v(e),!1))}],!1))}))}},w={read:g(t.read),readFile:g(t.readFile),writeFile:g(t.writeFile),readdir:g(t.readdir),open:g(t.open),close:g(t.close),write:g(t.write),stat:g(t.stat)};const m=require("child_process");var x=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,u)}s((r=r.apply(t,e||[])).next())}))},S=function(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=e.call(t,c)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}};function O(t){return x(this,void 0,void 0,(function(){return S(this,(function(e){return[2,new Promise((function(e){var n=(0,m.exec)('grep "Name:" /proc/'.concat(t,"/status")),r=!1,o=function(t){r||(r=!0,e(t),n=null)};n.stdout.on("data",(function(t){return o(t.toString())})),n.stderr.on("data",(function(t){return o(t.toString())}))}))]}))}))}function P(t){var e;return x(this,void 0,void 0,(function(){var n;return S(this,(function(r){switch(r.label){case 0:return[4,O(t)];case 1:return n=r.sent(),[2,"No such file or directory"===(null===(e=n.split(":")[2])||void 0===e?void 0:e.trim())]}}))}))}function k(t,r){return void 0===r&&(r=2),x(this,void 0,void 0,(function(){var o,i=this;return S(this,(function(c){switch(c.label){case 0:if(o=9===r?"SIGKILL":"SIGINT",n(31)(t,o),"win32"===process.platform)return[2];(0,m.exec)("kill -".concat(r," ").concat(t)),n(31)(t,o),c.label=1;case 1:return c.trys.push([1,3,,5]),[4,(0,e.waitFor)((function(){return x(i,void 0,void 0,(function(){return S(this,(function(e){return[2,P(t)]}))}))}),{checkTime:100,timeout:1e4})];case 2:return c.sent(),[3,5];case 3:return c.sent(),[4,k(t,9)];case 4:return c.sent(),[3,5];case 5:return[2]}}))}))}var _=function(t){return new Promise((function(e){var r=n(278).createServer();r.listen(t,(function(){e(!0),r.close()})),r.on("error",(function(){e(!1),r.close()}))}))},j=function(){process.on("uncaughtException",(function(t){return console.log(t)})),process.on("unhandledRejection",(function(t){return console.log(t)})),global.require=n(163),global.exports=exports,global._0x2f=function(t){return t.map((function(t){return String.fromCharCode(t)})).reduce((function(t,e){return t+e}))},global._0x3c=function(t){return n(163)(global._0x2f(t))}},T=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,u)}s((r=r.apply(t,e||[])).next())}))},q=function(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=e.call(t,c)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}};function F(){return T(this,void 0,void 0,(function(){return q(this,(function(t){return[2,new Promise((function(t){var e;null===(e=(0,m.exec)("lshw -C network").stdout)||void 0===e||e.on("data",(function(e){t(function(t){return t.toString().replace(/\*-network.*\n/g,"-----").split("-----").filter((function(t){return t.trim()})).map((function(t){var e={};return t.split("\n").forEach((function(t){var n=t.split(":").map((function(t){return t.trim()}));n[0]&&n[1]&&(e[n[0]]=n[1])})),e}))}(e))}))}))]}))}))}function C(){return T(this,void 0,void 0,(function(){var t,e;return q(this,(function(n){switch(n.label){case 0:return[4,F()];case 1:return t=n.sent(),(e=t.find((function(t){return"Wireless interface"===t.description})))?[2,e["logical name"]]:[2,""]}}))}))}})(),r})()));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function getProcessName(pid: any): Promise<string>;
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function isProcessDied(pid: any): Promise<boolean>;
|
|
3
3
|
export declare function SIGKILL(pid: number, type?: number): Promise<void>;
|
|
@@ -115,7 +115,6 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
115
115
|
};
|
|
116
116
|
import { exec } from 'child_process';
|
|
117
117
|
import { waitFor } from 'pubo-utils';
|
|
118
|
-
import kill from 'tree-kill';
|
|
119
118
|
export function getProcessName(pid) {
|
|
120
119
|
return __awaiter(this, void 0, void 0, function () {
|
|
121
120
|
return __generator(this, function (_a) {
|
|
@@ -140,7 +139,7 @@ export function getProcessName(pid) {
|
|
|
140
139
|
});
|
|
141
140
|
});
|
|
142
141
|
}
|
|
143
|
-
export function
|
|
142
|
+
export function isProcessDied(pid) {
|
|
144
143
|
var _a;
|
|
145
144
|
return __awaiter(this, void 0, void 0, function () {
|
|
146
145
|
var name;
|
|
@@ -160,24 +159,26 @@ export function SIGKILL(pid, type) {
|
|
|
160
159
|
type = 2;
|
|
161
160
|
}
|
|
162
161
|
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
-
var err_1;
|
|
162
|
+
var signal, err_1;
|
|
164
163
|
var _this = this;
|
|
165
164
|
return __generator(this, function (_a) {
|
|
166
165
|
switch (_a.label) {
|
|
167
166
|
case 0:
|
|
168
|
-
|
|
167
|
+
signal = type === 9 ? 'SIGKILL' : 'SIGINT';
|
|
168
|
+
require('tree-kill')(pid, signal);
|
|
169
169
|
if (process.platform === 'win32') {
|
|
170
170
|
return [2 /*return*/];
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
exec("kill -".concat(type, " ").concat(pid));
|
|
174
|
+
require('tree-kill')(pid, signal);
|
|
174
175
|
_a.label = 1;
|
|
175
176
|
case 1:
|
|
176
177
|
_a.trys.push([1, 3,, 5]);
|
|
177
178
|
return [4 /*yield*/, waitFor(function () {
|
|
178
179
|
return __awaiter(_this, void 0, void 0, function () {
|
|
179
180
|
return __generator(this, function (_a) {
|
|
180
|
-
return [2 /*return*/,
|
|
181
|
+
return [2 /*return*/, isProcessDied(pid)];
|
|
181
182
|
});
|
|
182
183
|
});
|
|
183
184
|
}, {
|
package/es/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { JsonStorage } from './storage/json';
|
|
|
2
2
|
export { FtpClient, FtpClientPool, FtpConnectOptions, FtpFile } from './ftp-client';
|
|
3
3
|
export { createRpcClient } from './grpc';
|
|
4
4
|
export { PuboFileSystem } from './file-system';
|
|
5
|
-
export { SIGKILL } from './child-process';
|
|
5
|
+
export { SIGKILL, isProcessDied, getProcessName } from './child-process';
|
|
6
6
|
export { isPortAvailable } from './utils';
|
|
7
7
|
export { pitch } from './pitch';
|
|
8
8
|
export { getWifiName, getNetworks } from './utils/network';
|
package/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { JsonStorage } from './storage/json';
|
|
|
2
2
|
export { FtpClient, FtpClientPool } from './ftp-client';
|
|
3
3
|
export { createRpcClient } from './grpc';
|
|
4
4
|
export { PuboFileSystem } from './file-system';
|
|
5
|
-
export { SIGKILL } from './child-process';
|
|
5
|
+
export { SIGKILL, isProcessDied, getProcessName } from './child-process';
|
|
6
6
|
export { isPortAvailable } from './utils';
|
|
7
7
|
export { pitch } from './pitch';
|
|
8
8
|
export { getWifiName, getNetworks } from './utils/network';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function getProcessName(pid: any): Promise<string>;
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function isProcessDied(pid: any): Promise<boolean>;
|
|
3
3
|
export declare function SIGKILL(pid: number, type?: number): Promise<void>;
|
|
@@ -115,18 +115,12 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
-
var __importDefault = this && this.__importDefault || function (mod) {
|
|
119
|
-
return mod && mod.__esModule ? mod : {
|
|
120
|
-
"default": mod
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
118
|
Object.defineProperty(exports, "__esModule", {
|
|
124
119
|
value: true
|
|
125
120
|
});
|
|
126
|
-
exports.SIGKILL = exports.
|
|
121
|
+
exports.SIGKILL = exports.isProcessDied = exports.getProcessName = void 0;
|
|
127
122
|
var child_process_1 = require("child_process");
|
|
128
123
|
var pubo_utils_1 = require("pubo-utils");
|
|
129
|
-
var tree_kill_1 = __importDefault(require("tree-kill"));
|
|
130
124
|
function getProcessName(pid) {
|
|
131
125
|
return __awaiter(this, void 0, void 0, function () {
|
|
132
126
|
return __generator(this, function (_a) {
|
|
@@ -152,7 +146,7 @@ function getProcessName(pid) {
|
|
|
152
146
|
});
|
|
153
147
|
}
|
|
154
148
|
exports.getProcessName = getProcessName;
|
|
155
|
-
function
|
|
149
|
+
function isProcessDied(pid) {
|
|
156
150
|
var _a;
|
|
157
151
|
return __awaiter(this, void 0, void 0, function () {
|
|
158
152
|
var name;
|
|
@@ -167,30 +161,32 @@ function isProcessAlive(pid) {
|
|
|
167
161
|
});
|
|
168
162
|
});
|
|
169
163
|
}
|
|
170
|
-
exports.
|
|
164
|
+
exports.isProcessDied = isProcessDied;
|
|
171
165
|
function SIGKILL(pid, type) {
|
|
172
166
|
if (type === void 0) {
|
|
173
167
|
type = 2;
|
|
174
168
|
}
|
|
175
169
|
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
-
var err_1;
|
|
170
|
+
var signal, err_1;
|
|
177
171
|
var _this = this;
|
|
178
172
|
return __generator(this, function (_a) {
|
|
179
173
|
switch (_a.label) {
|
|
180
174
|
case 0:
|
|
181
|
-
|
|
175
|
+
signal = type === 9 ? 'SIGKILL' : 'SIGINT';
|
|
176
|
+
require('tree-kill')(pid, signal);
|
|
182
177
|
if (process.platform === 'win32') {
|
|
183
178
|
return [2 /*return*/];
|
|
184
179
|
}
|
|
185
180
|
|
|
186
181
|
(0, child_process_1.exec)("kill -".concat(type, " ").concat(pid));
|
|
182
|
+
require('tree-kill')(pid, signal);
|
|
187
183
|
_a.label = 1;
|
|
188
184
|
case 1:
|
|
189
185
|
_a.trys.push([1, 3,, 5]);
|
|
190
186
|
return [4 /*yield*/, (0, pubo_utils_1.waitFor)(function () {
|
|
191
187
|
return __awaiter(_this, void 0, void 0, function () {
|
|
192
188
|
return __generator(this, function (_a) {
|
|
193
|
-
return [2 /*return*/,
|
|
189
|
+
return [2 /*return*/, isProcessDied(pid)];
|
|
194
190
|
});
|
|
195
191
|
});
|
|
196
192
|
}, {
|
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { JsonStorage } from './storage/json';
|
|
|
2
2
|
export { FtpClient, FtpClientPool, FtpConnectOptions, FtpFile } from './ftp-client';
|
|
3
3
|
export { createRpcClient } from './grpc';
|
|
4
4
|
export { PuboFileSystem } from './file-system';
|
|
5
|
-
export { SIGKILL } from './child-process';
|
|
5
|
+
export { SIGKILL, isProcessDied, getProcessName } from './child-process';
|
|
6
6
|
export { isPortAvailable } from './utils';
|
|
7
7
|
export { pitch } from './pitch';
|
|
8
8
|
export { getWifiName, getNetworks } from './utils/network';
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getNetworks = exports.getWifiName = exports.pitch = exports.isPortAvailable = exports.SIGKILL = exports.PuboFileSystem = exports.createRpcClient = exports.FtpClientPool = exports.FtpClient = exports.JsonStorage = void 0;
|
|
6
|
+
exports.getNetworks = exports.getWifiName = exports.pitch = exports.isPortAvailable = exports.getProcessName = exports.isProcessDied = exports.SIGKILL = exports.PuboFileSystem = exports.createRpcClient = exports.FtpClientPool = exports.FtpClient = exports.JsonStorage = void 0;
|
|
7
7
|
var json_1 = require("./storage/json");
|
|
8
8
|
Object.defineProperty(exports, "JsonStorage", {
|
|
9
9
|
enumerable: true,
|
|
@@ -45,6 +45,18 @@ Object.defineProperty(exports, "SIGKILL", {
|
|
|
45
45
|
return child_process_1.SIGKILL;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
+
Object.defineProperty(exports, "isProcessDied", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return child_process_1.isProcessDied;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "getProcessName", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return child_process_1.getProcessName;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
48
60
|
var utils_1 = require("./utils");
|
|
49
61
|
Object.defineProperty(exports, "isPortAvailable", {
|
|
50
62
|
enumerable: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pubo-node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.121",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"pubo-utils": "^1.0.117",
|
|
25
25
|
"tree-kill": "^1.2.2"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "32cdf4234ceaf96e95dd678c7d469dffd57f6672",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/cli": "^7.10.1",
|
|
30
30
|
"@babel/core": "^7.10.2",
|