locadot 1.4.1 → 1.5.1

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/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
  ## 🚀 Usage
15
15
 
16
16
  ```bash
17
- npx locadot --host dev.localhost --port 3350
17
+ npx locadot add --host dev.localhost --port 3350
18
18
  ```
19
19
 
20
20
  ---
@@ -26,7 +26,24 @@ npx locadot --host dev.localhost --port 3350
26
26
  ###### Starts a reverse proxy to the specified localhost port.
27
27
 
28
28
  ```bash
29
- npx locadot --host <custom.localhost> --port <localhost-port>
29
+ npx locadot add --host <custom.localhost> --port <localhost-port>
30
+ ```
31
+
32
+ ##### 🧾 Update existing host
33
+
34
+ ###### Update domains currently registered with locadot.
35
+
36
+ ```bash
37
+ npx locadot update --host <your.localhost> --port <localhost-port>
38
+ ```
39
+
40
+
41
+ ##### 🧾 Remove existing host
42
+
43
+ ###### Remove domains currently registered with locadot.
44
+
45
+ ```bash
46
+ npx locadot remove --host <your.localhost>
30
47
  ```
31
48
 
32
49
  ##### 🧾 View Registered Hosts
@@ -42,7 +59,7 @@ npx locadot host
42
59
  ###### Continuously watches and outputs proxy logs in real time.
43
60
 
44
61
  ```bash
45
- npx locadot watch logs
62
+ npx locadot watch:logs
46
63
  ```
47
64
 
48
65
  ##### 🧹 Clear Logs
@@ -50,15 +67,42 @@ npx locadot watch logs
50
67
  ###### Clears all saved logs.
51
68
 
52
69
  ```bash
53
- npx locadot clear logs
70
+ npx locadot clear:logs
54
71
  ```
72
+
73
+ ##### 🧹 Clear Hosts
74
+
75
+ ###### Clears all existing hosts.
76
+
77
+ ```bash
78
+ npx locadot clear:hosts
79
+ ```
80
+
81
+ ##### 🧹 Show Config Path
82
+
83
+ ###### Print the path of config files used.
84
+
85
+ ```bash
86
+ npx locadot path
87
+ ```
88
+
55
89
  ##### 🧹 Show Logs Path
56
90
 
57
91
  ###### Print the path of logged files used.
58
92
 
59
93
  ```bash
60
- npx locadot path logs
94
+ npx locadot path:logs
61
95
  ```
96
+
97
+
98
+ ##### 🧹 Show Hosts Path
99
+
100
+ ###### Print the path of hosts files used.
101
+
102
+ ```bash
103
+ npx locadot path:hosts
104
+ ```
105
+
62
106
  ##### 🔄 Restart Proxy
63
107
 
64
108
  ###### Restarts the proxy server and reloads configuration.
@@ -3,21 +3,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.errorConstants = exports.locadotPath = void 0;
7
6
  const appdata_path_1 = __importDefault(require("appdata-path"));
8
7
  const path_1 = __importDefault(require("path"));
9
8
  const PACKAGE_PATH = (0, appdata_path_1.default)("locadot");
9
+ const LOGS = path_1.default.join(PACKAGE_PATH, ".locadot.log");
10
10
  const LOCK_FILE = path_1.default.join(PACKAGE_PATH, ".locadot.lock");
11
11
  const REGISTRY_FILE = path_1.default.join(PACKAGE_PATH, ".locadot-registry.json");
12
- const LOGS = path_1.default.join(PACKAGE_PATH, ".locadot.log");
13
- exports.locadotPath = {
14
- LOCK_FILE,
15
- REGISTRY_FILE,
16
- LOGS,
12
+ class Constants {
13
+ }
14
+ Constants.paths = {
15
+ LOCK_FILE: LOCK_FILE,
16
+ REGISTRY_FILE: REGISTRY_FILE,
17
+ LOGS: LOGS,
17
18
  };
18
- exports.errorConstants = {
19
+ Constants.proxyInfo = {
19
20
  invalidHost: "❌ Invalid domain. Please use a valid localhost domain like dev.localhost, localhost, test.localhost, etc.",
20
21
  hostExist: "❌ Domain already in use. Please choose another domain or stop the existing instance.",
22
+ hostNotFound: "❌ Domain not found. Please choose another domain or stop the existing instance.",
21
23
  proxyClose: "☑️ Successfully stopped all locadot instances.",
22
24
  softClose: "☑️ Successfully stopped central proxy..",
23
25
  };
26
+ exports.default = Constants;
package/dist/core.js CHANGED
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const locadot_file_1 = __importDefault(require("./lib/locadot-file"));
7
- const server_1 = __importDefault(require("./server"));
6
+ const proxy_1 = __importDefault(require("./proxy"));
7
+ const logger_1 = __importDefault(require("./utils/logger"));
8
8
  async function run() {
9
- locadot_file_1.default.updateLogs("🔄 Starting central proxy.");
10
- await server_1.default.startCentralProxy();
11
- locadot_file_1.default.updateLogs("☑️ Central proxy started.");
9
+ logger_1.default.info(`🔄 Starting central proxy.`);
10
+ await proxy_1.default.startCentralProxy();
11
+ logger_1.default.info("☑️ Central proxy started.");
12
12
  }
13
13
  run();
package/dist/index.js CHANGED
@@ -4,56 +4,97 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const yargs_1 = __importDefault(require("yargs"));
8
- const helpers_1 = require("yargs/helpers");
7
+ const commander_1 = require("commander");
9
8
  const commands_1 = __importDefault(require("./lib/commands"));
10
- const constants_1 = require("./utils/constants");
11
- async function run() {
12
- await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
13
- .scriptName("locadot")
14
- .usage("Usage: npx locadot --host local.dev --port 3350")
15
- .command("$0", "Run the proxy with a domain and port", (yargs) => {
16
- return yargs
17
- .option("host", {
18
- alias: "h",
19
- describe: "Domain to map (must point to 127.0.0.1 in hosts file)",
20
- demandOption: true,
21
- type: "string",
22
- })
23
- .option("port", {
24
- alias: "p",
25
- describe: "Local port to forward to",
26
- demandOption: true,
27
- type: "number",
28
- });
29
- }, async (argv) => {
30
- await commands_1.default.start(argv);
31
- })
32
- .command("host", "Show all hosts.", () => {
33
- commands_1.default.getRegistry();
34
- })
35
- .command("watch logs", "Watch log files", () => { }, async (argv) => {
36
- commands_1.default.watchLogs();
37
- })
38
- .command("clear logs", "Clear logs", () => { }, async (argv) => {
39
- commands_1.default.clearLogs();
40
- })
41
- .command("path logs", "Show log path", () => { }, async (argv) => {
42
- commands_1.default.logPath();
43
- })
44
- .command("restart", "Restart locadot", () => { }, async (argv) => {
45
- commands_1.default.restart();
46
- })
47
- .command("stop", "Stop central proxy and logs.", () => { }, async (argv) => {
48
- await commands_1.default.stop();
49
- console.log(constants_1.errorConstants.proxyClose);
50
- process.exit(0);
51
- })
52
- .command("kill", "Stop central proxy and clear all logs and also port mapping.", () => { }, async (argv) => {
53
- await commands_1.default.kill();
54
- console.log(constants_1.errorConstants.proxyClose);
55
- process.exit(0);
56
- })
57
- .help().argv;
58
- }
59
- run();
9
+ const logger_1 = __importDefault(require("./utils/logger"));
10
+ const package_json_1 = require("../package.json");
11
+ const constants_1 = __importDefault(require("./constants"));
12
+ const program = new commander_1.Command();
13
+ program
14
+ .name("locadot")
15
+ .description("Locadot CLI - Local domain proxy manager")
16
+ .version(package_json_1.version);
17
+ program
18
+ .command("add")
19
+ .description("Add a new localhost domain and port")
20
+ .requiredOption("-h, --host <host>", "Domain to map must be ends with localhost. Example: dev.localhost, localhost, test.localhost, etc.")
21
+ .requiredOption("-p, --port <port>", "Local port to forward to")
22
+ .action(async (options) => {
23
+ await commands_1.default.add(options);
24
+ });
25
+ program
26
+ .command("update")
27
+ .requiredOption("-h, --host <host>", "Domain to map must be ends with localhost. Example: dev.localhost, localhost, test.localhost, etc.")
28
+ .requiredOption("-p, --port <port>", "Local port to forward to")
29
+ .description("Update a domain")
30
+ .action(async (options) => await commands_1.default.update(options));
31
+ program
32
+ .command("remove")
33
+ .requiredOption("-h, --host <host>", "Host must ends with localhost. Example: dev.localhost, localhost, test.localhost, etc.")
34
+ .description("Remove a domain")
35
+ .action(async (options) => await commands_1.default.remove(options));
36
+ program
37
+ .command("host")
38
+ .description("Show all hosts")
39
+ .action(() => {
40
+ commands_1.default.getRegistry();
41
+ });
42
+ program
43
+ .command("watch:logs")
44
+ .description("Watch log files")
45
+ .action(() => {
46
+ commands_1.default.watchLogs();
47
+ });
48
+ program
49
+ .command("clear:logs")
50
+ .description("Clear logs")
51
+ .action(() => {
52
+ commands_1.default.clearLogs();
53
+ });
54
+ program
55
+ .command("clear:hosts")
56
+ .description("Clear all host file.")
57
+ .action(() => {
58
+ commands_1.default.clearHosts();
59
+ });
60
+ program
61
+ .command("path")
62
+ .description("Show configuration paths.")
63
+ .action(() => {
64
+ commands_1.default.configPath();
65
+ });
66
+ program
67
+ .command("path:logs")
68
+ .description("Show logs path file.")
69
+ .action(() => {
70
+ commands_1.default.logPath();
71
+ });
72
+ program
73
+ .command("path:hosts")
74
+ .description("Show hosts path file.")
75
+ .action(() => {
76
+ commands_1.default.hostPath();
77
+ });
78
+ program
79
+ .command("restart")
80
+ .description("Restart locadot")
81
+ .action(() => {
82
+ commands_1.default.restart();
83
+ });
84
+ program
85
+ .command("stop")
86
+ .description("Stop central proxy and logs")
87
+ .action(async () => {
88
+ await commands_1.default.stop();
89
+ logger_1.default.info(constants_1.default.proxyInfo.softClose);
90
+ process.exit(0);
91
+ });
92
+ program
93
+ .command("kill")
94
+ .description("Stop proxy, clear logs, and hosts file.")
95
+ .action(async () => {
96
+ await commands_1.default.kill();
97
+ logger_1.default.info(constants_1.default.proxyInfo.softClose);
98
+ process.exit(0);
99
+ });
100
+ program.parse(process.argv);
@@ -4,37 +4,74 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const localhost_1 = __importDefault(require("./localhost"));
7
- const constants_1 = require("../utils/constants");
8
- const server_1 = __importDefault(require("../server"));
7
+ const proxy_1 = __importDefault(require("../proxy"));
9
8
  const locadot_file_1 = __importDefault(require("./locadot-file"));
9
+ const constants_1 = __importDefault(require("../constants"));
10
10
  class Commands {
11
- static async start(argv) {
11
+ static async add(argv) {
12
12
  if (!localhost_1.default.isValidLocalhostDomain(argv.host)) {
13
- console.error(constants_1.errorConstants.invalidHost);
13
+ console.error(constants_1.default.proxyInfo.invalidHost);
14
14
  process.exit(1);
15
15
  }
16
16
  if (await localhost_1.default.isLocalhostOpen(argv.host, argv.port)) {
17
- console.error(constants_1.errorConstants.hostExist);
17
+ console.error(constants_1.default.proxyInfo.hostExist);
18
+ process.exit(1);
18
19
  }
19
20
  try {
20
- await server_1.default.registerDomain(argv.host, argv.port);
21
+ await proxy_1.default.addProxy(argv.host, argv.port);
22
+ }
23
+ catch (error) {
24
+ console.error(error);
25
+ }
26
+ }
27
+ static async remove(argv) {
28
+ if (!localhost_1.default.isValidLocalhostDomain(argv.host)) {
29
+ console.error(constants_1.default.proxyInfo.invalidHost);
30
+ process.exit(1);
31
+ }
32
+ try {
33
+ await proxy_1.default.removeProxy(argv.host);
34
+ }
35
+ catch (error) {
36
+ console.error(error);
37
+ }
38
+ }
39
+ static async update(argv) {
40
+ if (!localhost_1.default.isValidLocalhostDomain(argv.host)) {
41
+ console.error(constants_1.default.proxyInfo.invalidHost);
42
+ process.exit(1);
43
+ }
44
+ if (!(await localhost_1.default.isLocalhostOpen(argv.host, argv.port))) {
45
+ console.error(constants_1.default.proxyInfo.hostNotFound);
46
+ process.exit(1);
47
+ }
48
+ try {
49
+ await proxy_1.default.updateProxy(argv.host, argv.port);
50
+ }
51
+ catch (error) {
52
+ console.error(error);
21
53
  }
22
- catch (error) { }
23
54
  }
24
55
  static async stop() {
25
56
  try {
26
- await server_1.default.stopProxy();
57
+ await proxy_1.default.stopProxy();
58
+ }
59
+ catch (error) { }
60
+ }
61
+ static async clearHosts() {
62
+ try {
63
+ await locadot_file_1.default.removeAllRegistry();
27
64
  }
28
65
  catch (error) { }
29
66
  }
30
67
  static async kill() {
31
68
  try {
32
- await server_1.default.killProxy();
69
+ await proxy_1.default.killProxy();
33
70
  }
34
71
  catch (error) { }
35
72
  }
36
73
  static async restart() {
37
- await server_1.default.restartProxy();
74
+ await proxy_1.default.restartProxy();
38
75
  console.log("☑️ Proxy successfully restarted.");
39
76
  }
40
77
  static async getRegistry() {
@@ -47,7 +84,6 @@ class Commands {
47
84
  }
48
85
  static watchLogs() {
49
86
  try {
50
- console.log("☑️ Watching logs files.");
51
87
  locadot_file_1.default.watchLogs();
52
88
  }
53
89
  catch (error) { }
@@ -60,7 +96,14 @@ class Commands {
60
96
  catch (error) { }
61
97
  }
62
98
  static async logPath() {
63
- console.log(constants_1.locadotPath.LOGS);
99
+ console.log(constants_1.default.paths.LOGS);
100
+ }
101
+ static async hostPath() {
102
+ console.log(constants_1.default.paths.REGISTRY_FILE);
103
+ }
104
+ static async configPath() {
105
+ console.log(constants_1.default.paths.REGISTRY_FILE);
106
+ console.log(constants_1.default.paths.LOGS);
64
107
  }
65
108
  }
66
109
  exports.default = Commands;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const template_1 = require("../constants/template");
7
+ const logger_1 = __importDefault(require("../utils/logger"));
8
+ class HttpModule {
9
+ static requestHandler(req, res, proxy, domainMap) {
10
+ try {
11
+ const host = req.headers.host?.split(":")[0];
12
+ const targetPort = domainMap[host];
13
+ if (!targetPort) {
14
+ res.writeHead(502, { "Content-Type": "text/html" });
15
+ res.end((0, template_1.proxyNotFound)(host));
16
+ }
17
+ proxy.web(req, res, {
18
+ target: `http://localhost:${targetPort}`,
19
+ changeOrigin: true,
20
+ headers: {
21
+ "X-Original-Host": host || "localhost",
22
+ },
23
+ }, (err) => {
24
+ logger_1.default.warn(host || "", "warn", `${err.name}=> ${err.message}`);
25
+ res.writeHead(502);
26
+ res.end("Connection failed. Host not found.");
27
+ });
28
+ }
29
+ catch (error) {
30
+ logger_1.default.error(error);
31
+ }
32
+ }
33
+ }
34
+ HttpModule.requestUpgrade = (req, socket, head, proxy, domainMap) => {
35
+ try {
36
+ const host = req.headers.host?.split(":")[0];
37
+ const targetPort = domainMap[host];
38
+ if (!targetPort) {
39
+ socket.end();
40
+ return;
41
+ }
42
+ logger_1.default.info(host || "", "log", `WebSocket upgrade request for ${host}`);
43
+ proxy.ws(req, socket, head, {
44
+ target: `ws://localhost:${targetPort}`,
45
+ ws: true,
46
+ changeOrigin: true,
47
+ headers: {
48
+ host: `localhost:${targetPort}`,
49
+ "X-Original-Host": host || "localhost",
50
+ },
51
+ }, (err) => {
52
+ // locadotFile.updateLogs(
53
+ // host || "",
54
+ // "warn",
55
+ // `WebSocket Error: ${err.name}=> ${err.message}`
56
+ // );
57
+ socket.end();
58
+ });
59
+ }
60
+ catch (error) {
61
+ logger_1.default.error(error);
62
+ }
63
+ };
64
+ exports.default = HttpModule;
@@ -3,110 +3,92 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const constants_1 = require("../utils/constants");
7
- const fs_1 = __importDefault(require("fs"));
8
- const date_fns_1 = require("date-fns");
6
+ const file_1 = __importDefault(require("../utils/file"));
7
+ const logger_1 = __importDefault(require("../utils/logger"));
8
+ const path_1 = __importDefault(require("path"));
9
9
  class locadotFile {
10
10
  static async createLockFile(processId) {
11
- fs_1.default.writeFileSync(constants_1.locadotPath.LOCK_FILE, processId);
11
+ await file_1.default.writeFileSync("LOCK_FILE", processId);
12
12
  }
13
13
  static async getProcessId() {
14
14
  try {
15
- if (fs_1.default.existsSync(constants_1.locadotPath.LOCK_FILE)) {
16
- const pid = parseInt(fs_1.default.readFileSync(constants_1.locadotPath.LOCK_FILE, "utf-8"));
17
- return pid.toString();
18
- }
15
+ const lockFile = await file_1.default.readFileSync("LOCK_FILE");
16
+ return parseInt(lockFile).toString();
19
17
  }
20
18
  catch (err) {
19
+ await file_1.default.removeFileSync("LOCK_FILE");
21
20
  return;
22
21
  }
23
22
  }
24
23
  static async deleteLockFile() {
25
- fs_1.default.rmSync(constants_1.locadotPath.LOCK_FILE);
24
+ await file_1.default.removeFileSync("LOCK_FILE");
26
25
  }
27
26
  static async getRegistry() {
28
- if (!fs_1.default.existsSync(constants_1.locadotPath.REGISTRY_FILE)) {
29
- fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, "{}");
27
+ try {
28
+ return JSON.parse(await file_1.default.readFileSync("REGISTRY_FILE"));
29
+ }
30
+ catch (error) {
31
+ logger_1.default.error(error);
32
+ return {};
30
33
  }
31
- return JSON.parse(fs_1.default.readFileSync(constants_1.locadotPath.REGISTRY_FILE, "utf-8"));
32
34
  }
33
35
  static async addRegistry(domain, port) {
34
36
  const registry = await locadotFile.getRegistry();
35
37
  registry[domain] = port;
36
- fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, JSON.stringify(registry, null, 2));
38
+ file_1.default.writeFileSync("REGISTRY_FILE", JSON.stringify(registry));
37
39
  }
38
40
  static async removeAllRegistry() {
39
- fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, "{}");
41
+ file_1.default.writeFileSync("REGISTRY_FILE", "{}");
40
42
  }
41
43
  static async updateRegistry(domain, port) {
42
44
  const registry = await locadotFile.getRegistry();
43
45
  registry[domain] = port;
44
- fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, JSON.stringify(registry, null, 2));
46
+ file_1.default.writeFileSync("REGISTRY_FILE", JSON.stringify(registry));
45
47
  }
46
48
  static async deleteRegistry(domain) {
47
49
  const registry = await locadotFile.getRegistry();
48
50
  delete registry[domain];
49
- fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, JSON.stringify(registry, null, 2));
51
+ file_1.default.writeFileSync("REGISTRY_FILE", JSON.stringify(registry));
50
52
  }
51
53
  static async watchRegistry(callBackOnChange) {
52
- return fs_1.default.watch(constants_1.locadotPath.REGISTRY_FILE, async (eventType) => {
53
- if (eventType === "change") {
54
- this.updateLogs("🔄 Updated domain mappings.");
55
- callBackOnChange && callBackOnChange();
56
- }
57
- });
54
+ return file_1.default.watchFileWithInit("REGISTRY_FILE", () => callBackOnChange?.());
58
55
  }
59
56
  static async getLogs() {
60
- if (!fs_1.default.existsSync(constants_1.locadotPath.LOGS)) {
61
- fs_1.default.writeFileSync(constants_1.locadotPath.LOGS, "{}");
57
+ try {
58
+ return await file_1.default.readFileSync("LOGS");
62
59
  }
63
- return JSON.parse(fs_1.default.readFileSync(constants_1.locadotPath.LOGS, "utf-8"));
64
- }
65
- static async updateLogs(message, status = "log", description) {
66
- const logs = (await locadotFile.getLogs()).logs || [];
67
- if (!Array.isArray(logs)) {
68
- fs_1.default.writeFileSync(constants_1.locadotPath.LOGS, "{}");
60
+ catch (error) {
61
+ file_1.default.removeFileSync("LOGS");
62
+ return "";
69
63
  }
70
- logs.push({
71
- message,
72
- timestamp: Date.now(),
73
- status: status,
74
- description,
75
- });
76
- fs_1.default.writeFileSync(constants_1.locadotPath.LOGS, JSON.stringify({ logs: logs }));
77
64
  }
78
65
  static async clearLogs() {
79
- fs_1.default.writeFileSync(constants_1.locadotPath.LOGS, "{}");
80
- }
81
- static async printLogs(log) {
82
- console[log.status || "log"](`${(0, date_fns_1.format)(log.timestamp, "yyyy-MM-dd HH:mm:ss")}: ${log.message} ${log.description ? "==> " : ""}${log.description ? log.description : ""}\n`);
66
+ file_1.default.writeFileSync("LOGS", "");
83
67
  }
84
68
  static async watchLogs() {
85
- const logs = await locadotFile.getLogs();
86
- let length = logs.logs?.length || 0;
87
- logs.logs?.forEach((log) => this.printLogs(log));
88
- fs_1.default.watch(constants_1.locadotPath.LOGS, async (eventType) => {
89
- try {
90
- if (eventType === "change") {
91
- const newLog = await locadotFile.getLogs();
92
- newLog.logs?.forEach((log, i) => {
93
- if (i > length - 1) {
94
- this.printLogs(log);
95
- }
96
- });
97
- length = newLog.logs?.length || 0;
98
- }
99
- }
100
- catch (error) { }
101
- });
69
+ file_1.default.tailFile("LOGS");
70
+ }
71
+ static getStartProxyFile() {
72
+ if (process.env.NODE_ENV === "production") {
73
+ const filePath = path_1.default.join(__dirname, "..", "core.js");
74
+ return {
75
+ command: "node",
76
+ path: [filePath],
77
+ };
78
+ }
79
+ const filePath = path_1.default.join(__dirname, "../../", "dist", "core.js");
80
+ return {
81
+ command: "node",
82
+ path: [filePath],
83
+ };
102
84
  }
103
85
  static async destroy(watcher) {
104
86
  try {
105
87
  const pid = await locadotFile.getProcessId();
106
- locadotFile.deleteLockFile();
107
- locadotFile.removeAllRegistry();
108
- locadotFile.clearLogs();
109
- watcher?.close();
88
+ await locadotFile.deleteLockFile();
89
+ await locadotFile.removeAllRegistry();
90
+ await locadotFile.clearLogs();
91
+ await watcher?.close();
110
92
  if (pid) {
111
93
  process.kill(parseInt(pid));
112
94
  }
@@ -116,14 +98,16 @@ class locadotFile {
116
98
  static async softDestroy(watcher) {
117
99
  try {
118
100
  const pid = await locadotFile.getProcessId();
119
- locadotFile.deleteLockFile();
120
- locadotFile.clearLogs();
121
- watcher?.close();
101
+ await locadotFile.deleteLockFile();
102
+ await locadotFile.clearLogs();
103
+ await watcher?.close();
122
104
  if (pid) {
123
105
  process.kill(parseInt(pid));
124
106
  }
125
107
  }
126
- catch (error) { }
108
+ catch (error) {
109
+ logger_1.default.error(error);
110
+ }
127
111
  }
128
112
  }
129
113
  exports.default = locadotFile;