UNPKG

@remote.it/core

Version:

Core remote.it JavasScript/TypeScript library

55 lines 2.08 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var debug_1 = __importDefault(require("debug")); var child_process_1 = require("child_process"); var d = debug_1.default('remoteit:LaunchCtl'); var LaunchCtl = /** @class */ (function () { function LaunchCtl(plist) { this.plist = plist; } LaunchCtl.prototype.load = function () { d('load:', this.plist.location); if (!this.plist.exists) throw new Error('plist file does not exist, cannot load service!'); child_process_1.execFileSync('launchctl', ['load', this.plist.location]); }; LaunchCtl.prototype.start = function () { d('start:', this.plist.location); if (!this.plist.exists) throw new Error('plist file does not exist, cannot start service!'); child_process_1.execFileSync('launchctl', ['start', this.plist.label]); }; LaunchCtl.prototype.stop = function () { d('stop:', this.plist.location); if (!this.plist.exists) return; child_process_1.execFileSync('launchctl', ['stop', this.plist.label]); }; LaunchCtl.prototype.unload = function () { d('unload:', this.plist.location); if (!this.plist.exists) return; child_process_1.execFileSync('launchctl', ['unload', this.plist.location]); }; LaunchCtl.prototype.remove = function () { d('remove:', this.plist.location); if (!this.plist.exists) return; try { child_process_1.execFileSync('launchctl', ['remove', this.plist.location]); } catch (error) { if (error && error.status && error.status === 3) { d('cannot remove as process is not running'); return; } throw error; } }; return LaunchCtl; }()); exports.LaunchCtl = LaunchCtl; //# sourceMappingURL=LaunchCtl.js.map