pubo-node 1.0.117 → 1.0.119
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
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){return O(this,void 0,void 0,(function(){var n=this;return P(this,(function(r){switch(r.label){case 0:if(S()(t,"SIGINT"),"win32"===process.platform)return[2];(0,m.exec)("kill -2 ".concat(t)),r.label=1;case 1:return r.trys.push([1,3,,5]),[4,(0,e.waitFor)((function(){return O(n,void 0,void 0,(function(){return P(this,(function(e){return[2,k(t)]}))}))}),{checkTime:100,timeout:1e4})];case 2:return r.sent(),[3,5];case 3:return r.sent(),[4,j(t)];case 4:return r.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,getWifiName:()=>C,isPortAvailable:()=>_,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("win32"===process.platform)return o=9===r?"SIGKILL":"SIGINT",n(31)(t,o),[2];(0,m.exec)("kill -".concat(r," ").concat(t)),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
2
|
export declare function isProcessAlive(pid: any): Promise<boolean>;
|
|
3
|
-
export declare function SIGKILL(pid: number): Promise<void>;
|
|
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) {
|
|
@@ -155,19 +154,23 @@ export function isProcessAlive(pid) {
|
|
|
155
154
|
});
|
|
156
155
|
});
|
|
157
156
|
}
|
|
158
|
-
export function SIGKILL(pid) {
|
|
157
|
+
export function SIGKILL(pid, type) {
|
|
158
|
+
if (type === void 0) {
|
|
159
|
+
type = 2;
|
|
160
|
+
}
|
|
159
161
|
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
-
var err_1;
|
|
162
|
+
var signal, err_1;
|
|
161
163
|
var _this = this;
|
|
162
164
|
return __generator(this, function (_a) {
|
|
163
165
|
switch (_a.label) {
|
|
164
166
|
case 0:
|
|
165
|
-
kill(pid, 'SIGINT');
|
|
166
167
|
if (process.platform === 'win32') {
|
|
168
|
+
signal = type === 9 ? 'SIGKILL' : 'SIGINT';
|
|
169
|
+
require('tree-kill')(pid, signal);
|
|
167
170
|
return [2 /*return*/];
|
|
168
171
|
}
|
|
169
172
|
|
|
170
|
-
exec("kill -
|
|
173
|
+
exec("kill -".concat(type, " ").concat(pid));
|
|
171
174
|
_a.label = 1;
|
|
172
175
|
case 1:
|
|
173
176
|
_a.trys.push([1, 3,, 5]);
|
|
@@ -186,7 +189,7 @@ export function SIGKILL(pid) {
|
|
|
186
189
|
return [3 /*break*/, 5];
|
|
187
190
|
case 3:
|
|
188
191
|
err_1 = _a.sent();
|
|
189
|
-
return [4 /*yield*/, SIGKILL(pid)];
|
|
192
|
+
return [4 /*yield*/, SIGKILL(pid, 9)];
|
|
190
193
|
case 4:
|
|
191
194
|
_a.sent();
|
|
192
195
|
return [3 /*break*/, 5];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function getProcessName(pid: any): Promise<string>;
|
|
2
2
|
export declare function isProcessAlive(pid: any): Promise<boolean>;
|
|
3
|
-
export declare function SIGKILL(pid: number): Promise<void>;
|
|
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
121
|
exports.SIGKILL = exports.isProcessAlive = 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) {
|
|
@@ -168,19 +162,23 @@ function isProcessAlive(pid) {
|
|
|
168
162
|
});
|
|
169
163
|
}
|
|
170
164
|
exports.isProcessAlive = isProcessAlive;
|
|
171
|
-
function SIGKILL(pid) {
|
|
165
|
+
function SIGKILL(pid, type) {
|
|
166
|
+
if (type === void 0) {
|
|
167
|
+
type = 2;
|
|
168
|
+
}
|
|
172
169
|
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
-
var err_1;
|
|
170
|
+
var signal, err_1;
|
|
174
171
|
var _this = this;
|
|
175
172
|
return __generator(this, function (_a) {
|
|
176
173
|
switch (_a.label) {
|
|
177
174
|
case 0:
|
|
178
|
-
(0, tree_kill_1["default"])(pid, 'SIGINT');
|
|
179
175
|
if (process.platform === 'win32') {
|
|
176
|
+
signal = type === 9 ? 'SIGKILL' : 'SIGINT';
|
|
177
|
+
require('tree-kill')(pid, signal);
|
|
180
178
|
return [2 /*return*/];
|
|
181
179
|
}
|
|
182
180
|
|
|
183
|
-
(0, child_process_1.exec)("kill -
|
|
181
|
+
(0, child_process_1.exec)("kill -".concat(type, " ").concat(pid));
|
|
184
182
|
_a.label = 1;
|
|
185
183
|
case 1:
|
|
186
184
|
_a.trys.push([1, 3,, 5]);
|
|
@@ -199,7 +197,7 @@ function SIGKILL(pid) {
|
|
|
199
197
|
return [3 /*break*/, 5];
|
|
200
198
|
case 3:
|
|
201
199
|
err_1 = _a.sent();
|
|
202
|
-
return [4 /*yield*/, SIGKILL(pid)];
|
|
200
|
+
return [4 /*yield*/, SIGKILL(pid, 9)];
|
|
203
201
|
case 4:
|
|
204
202
|
_a.sent();
|
|
205
203
|
return [3 /*break*/, 5];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pubo-node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.119",
|
|
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": "c76ece6f38adde1cfef5ad02e19f454a253ebaa5",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/cli": "^7.10.1",
|
|
30
30
|
"@babel/core": "^7.10.2",
|