jsnote-zeina 1.0.1 → 1.0.2

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.
@@ -23,7 +23,7 @@ exports.serveCommand = new commander_1.Command()
23
23
  .option('-p, --port <number>', 'port to run server on', '4005')
24
24
  .action((...args_1) => __awaiter(void 0, [...args_1], void 0, function* (filename = 'notebook.js', options) {
25
25
  const isLocalApiError = (err) => {
26
- return typeof err.code === 'string';
26
+ return typeof err === 'object' && err !== null && typeof err.code === 'string';
27
27
  };
28
28
  try {
29
29
  const dir = path_1.default.join(process.cwd(), path_1.default.dirname(filename)); // getting the directory
@@ -32,14 +32,16 @@ exports.serveCommand = new commander_1.Command()
32
32
  console.log(`Opened ${filename}. Navigate to http://localhost:${options.port} to edit the file.`);
33
33
  }
34
34
  catch (err) {
35
- if (isLocalApiError(err))
36
- if (err.code === 'EADDRINUSE') {
37
- console.log('Port is in use. Try running on a different port.');
38
- }
39
- else if (err instanceof Error) {
40
- console.log('Here is the problem: ', err.message);
41
- }
42
- process.exit(1); // Exit the program if express server does not start successfully
35
+ if (isLocalApiError(err) && err.code === 'EADDRINUSE') {
36
+ console.log('Port is in use. Try running on a different port.');
37
+ }
38
+ else if (err instanceof Error) {
39
+ console.log('Here is the problem: ', err.message);
40
+ }
41
+ else {
42
+ console.log('An unknown error occurred while starting the server.');
43
+ }
44
+ process.exit(1);
43
45
  }
44
46
  }));
45
47
  /*