Files
JiboSDK/node_modules/jibo-tools/lib/launcher/launcher.js
2026-03-22 03:21:45 +02:00

1 line
2.1 KiB
JavaScript

"use strict";var e=function(e){return e&&e.__esModule?e["default"]:e},t=function(){function e(e,t){for(var i in t){var r=t[i];r.configurable=!0,r.value&&(r.writable=!0)}Object.defineProperties(e,t)}return function(t,i,r){return i&&e(t.prototype,i),r&&e(t,r),t}}(),i=function h(e,t,i){var r=Object.getOwnPropertyDescriptor(e,t);if(void 0===r){var o=Object.getPrototypeOf(e);return null===o?void 0:h(o,t,i)}if("value"in r&&r.writable)return r.value;var n=r.get;if(void 0!==n)return n.call(i)},r=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)},o=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},n=require("child_process").spawn,s=e(require("../get-electron-path")),l=e(require("path")),c=require("events").EventEmitter,u=e(require("lodash")),a=function(e){function c(){o(this,c),i(Object.getPrototypeOf(c.prototype),"constructor",this).call(this),this.child=void 0,this.onChildExitBinded=this.onChildExit.bind(this)}return r(c,e),t(c,{onChildExit:{value:function(){this.child.removeAllListeners(),this.child=void 0,this.emit("exit")}},play:{value:function(e,t){var i=void 0===arguments[2]?"0123456789abcdefg":arguments[2];if(console.log("indexPath",e),console.log("remoteRegistry",t),!this.child){var r=l.resolve(__dirname,"..","..","electron"),o=[l.resolve(r,"main.js"),"--path",e,"--token",i];t&&t.length>0&&o.push("--remote",t);var c={ATOM_SHELL_INTERNAL_RUN_AS_NODE:"0"};process.env.hasOwnProperty("NODE_PATH_SIM")&&(process.env.hasOwnProperty("NODE_PATH")?c.NODE_PATH=process.env.NODE_PATH+":"+process.env.NODE_PATH_SIM:c.NODE_PATH=process.env.NODE_PATH_SIM),this.child=n(s(),o,{cwd:r,env:u.assign({},process.env,c),stdio:"inherit"}),this.emit("start"),this.child.on("exit",this.onChildExit.bind(this))}}},stop:{value:function(){this.child&&(console.log("STOP"),this.child.on("error",function(e){console.log(e)}),this.child.kill())}}}),c}(c);module.exports=new a;