lambda-live-debugger 0.0.99 → 0.0.100

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.
Binary file
@@ -1,12 +1,14 @@
1
1
  import fs from "fs/promises";
2
2
  import { outputFolder } from "./constants.mjs";
3
3
  import { Logger } from "./logger.mjs";
4
+ import { getProjectDirname } from "./getDirname.mjs";
5
+ import path from "path";
4
6
  /**
5
7
  * Check if ".lldebugger" exists in .gitignore
6
8
  */
7
9
  async function doesExistInGitIgnore() {
8
10
  try {
9
- const gitignoreContent = await fs.readFile(".gitignore", "utf-8");
11
+ const gitignoreContent = await fs.readFile(getGitIgnoreFileLocation(), "utf-8");
10
12
  // split by new line
11
13
  const lines = gitignoreContent.split("\n");
12
14
  // check if ".lldebugger" exists
@@ -17,6 +19,13 @@ async function doesExistInGitIgnore() {
17
19
  return false;
18
20
  }
19
21
  }
22
+ /**
23
+ * Get the location of .gitignore
24
+ * @returns
25
+ */
26
+ function getGitIgnoreFileLocation() {
27
+ return path.join(getProjectDirname(), ".gitignore");
28
+ }
20
29
  /**
21
30
  * Add ".lldebugger" to .gitignore if it doesn't exist
22
31
  * @returns
@@ -27,14 +36,14 @@ async function addToGitIgnore() {
27
36
  if (!exists) {
28
37
  // does file exist?
29
38
  try {
30
- await fs.access(".gitignore");
39
+ await fs.access(getGitIgnoreFileLocation());
31
40
  }
32
41
  catch (error) {
33
- await fs.writeFile(".gitignore", `${outputFolder}\n`);
42
+ await fs.writeFile(getGitIgnoreFileLocation(), `${outputFolder}\n`);
34
43
  return;
35
44
  }
36
45
  // append to existing file
37
- await fs.appendFile(".gitignore", `\n${outputFolder}\n`);
46
+ await fs.appendFile(getGitIgnoreFileLocation(), `\n${outputFolder}\n`);
38
47
  }
39
48
  else {
40
49
  Logger.log(`${outputFolder} already exists in .gitignore`);
@@ -47,9 +56,9 @@ async function removeFromGitIgnore() {
47
56
  Logger.verbose("Removing .gitignore entry...");
48
57
  const exists = await doesExistInGitIgnore();
49
58
  if (exists) {
50
- const gitignoreContent = await fs.readFile(".gitignore", "utf-8");
59
+ const gitignoreContent = await fs.readFile(getGitIgnoreFileLocation(), "utf-8");
51
60
  const newContent = gitignoreContent.replace(`${outputFolder}\n`, "");
52
- await fs.writeFile(".gitignore", newContent);
61
+ await fs.writeFile(getGitIgnoreFileLocation(), newContent);
53
62
  }
54
63
  else {
55
64
  Logger.log(`${outputFolder} doesn't exist in .gitignore`);
@@ -58,25 +58,25 @@ async function onMessageFromLambda(message) {
58
58
  }
59
59
  }
60
60
  if (Configuration.config.verbose) {
61
- Logger.verbose(`${message.data.functionId} response: `, JSON.stringify(message.data, null, 2));
61
+ Logger.verbose(`[Function ${message.data.functionId}] response: `, JSON.stringify(message.data, null, 2));
62
62
  }
63
63
  else {
64
64
  // first 50 characters of the response
65
65
  const requestPretty = message.data
66
66
  ? JSON.stringify(message.data).substring(0, 100)
67
67
  : "";
68
- Logger.log(`${message.data.functionId} request: ${requestPretty}${requestPretty.length < 50 ? "" : "..."}`);
68
+ Logger.log(`[Function ${message.data.functionId}] request: ${requestPretty}${requestPretty.length < 50 ? "" : "..."}`);
69
69
  }
70
70
  const response = await NodeHandler.invokeLambda(message.data);
71
71
  if (Configuration.config.verbose) {
72
- Logger.verbose(`${message.data.functionId} response: `, JSON.stringify(response, null, 2));
72
+ Logger.verbose(`[Function ${message.data.functionId}] response: `, JSON.stringify(response, null, 2));
73
73
  }
74
74
  else {
75
75
  // first 50 characters of the response
76
76
  const responsePretty = response
77
77
  ? JSON.stringify(response).substring(0, 100)
78
78
  : "";
79
- Logger.log(`${message.data.functionId} response: ${responsePretty}${responsePretty.length < 50 ? "" : "..."}`);
79
+ Logger.log(`[Function ${message.data.functionId}] response: ${responsePretty}${responsePretty.length < 50 ? "" : "..."}`);
80
80
  }
81
81
  if (Configuration.config.observable) {
82
82
  // if we are in observable mode, mark the worker as processed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambda-live-debugger",
3
- "version": "0.0.99",
3
+ "version": "0.0.100",
4
4
  "type": "module",
5
5
  "description": "Debug Lambda functions locally like it is running in the cloud",
6
6
  "repository": {