alex-c-line 1.3.1 → 1.3.3

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/dist/index.cjs CHANGED
@@ -90,17 +90,25 @@ var import_path2 = __toESM(require("path"), 1);
90
90
  var import_dotenv = __toESM(require("dotenv"), 1);
91
91
  var import_dotenv_stringify = __toESM(require("dotenv-stringify"), 1);
92
92
  function editEnv(program2) {
93
- program2.command("edit-env <key> <value>").description("Edit property in .env file ").action((key, value) => __async(null, null, function* () {
93
+ program2.command("edit-env <key> [value]").description("Edit property in .env file (leave value blank to delete property)").option("--file <file>", "The file to edit", ".env").action((_0, _1, _2) => __async(null, [_0, _1, _2], function* (key, value, { file }) {
94
+ let newValue = value;
95
+ if (typeof newValue === "string" && newValue.startsWith("--")) {
96
+ newValue = void 0;
97
+ }
94
98
  let currentEnvFileContents;
95
99
  try {
96
100
  currentEnvFileContents = import_dotenv.default.parse(
97
- yield (0, import_promises.readFile)(import_path2.default.join(process.cwd(), ".env"), "utf-8")
101
+ yield (0, import_promises.readFile)(import_path2.default.join(process.cwd(), file), "utf-8")
98
102
  );
99
103
  } catch (e) {
100
104
  currentEnvFileContents = {};
101
105
  }
102
- currentEnvFileContents[key] = value;
103
- yield (0, import_promises.writeFile)(import_path2.default.join(process.cwd(), ".env"), (0, import_dotenv_stringify.default)(currentEnvFileContents));
106
+ if (newValue !== void 0) {
107
+ currentEnvFileContents[key] = newValue;
108
+ } else {
109
+ delete currentEnvFileContents[key];
110
+ }
111
+ yield (0, import_promises.writeFile)(import_path2.default.join(process.cwd(), file), (0, import_dotenv_stringify.default)(currentEnvFileContents));
104
112
  console.log(".env file updated");
105
113
  }));
106
114
  }
package/dist/index.js CHANGED
@@ -69,17 +69,25 @@ import path2 from "path";
69
69
  import dotenv from "dotenv";
70
70
  import dotenvStringify from "dotenv-stringify";
71
71
  function editEnv(program2) {
72
- program2.command("edit-env <key> <value>").description("Edit property in .env file ").action((key, value) => __async(null, null, function* () {
72
+ program2.command("edit-env <key> [value]").description("Edit property in .env file (leave value blank to delete property)").option("--file <file>", "The file to edit", ".env").action((_0, _1, _2) => __async(null, [_0, _1, _2], function* (key, value, { file }) {
73
+ let newValue = value;
74
+ if (typeof newValue === "string" && newValue.startsWith("--")) {
75
+ newValue = void 0;
76
+ }
73
77
  let currentEnvFileContents;
74
78
  try {
75
79
  currentEnvFileContents = dotenv.parse(
76
- yield readFile(path2.join(process.cwd(), ".env"), "utf-8")
80
+ yield readFile(path2.join(process.cwd(), file), "utf-8")
77
81
  );
78
82
  } catch (e) {
79
83
  currentEnvFileContents = {};
80
84
  }
81
- currentEnvFileContents[key] = value;
82
- yield writeFile(path2.join(process.cwd(), ".env"), dotenvStringify(currentEnvFileContents));
85
+ if (newValue !== void 0) {
86
+ currentEnvFileContents[key] = newValue;
87
+ } else {
88
+ delete currentEnvFileContents[key];
89
+ }
90
+ yield writeFile(path2.join(process.cwd(), file), dotenvStringify(currentEnvFileContents));
83
91
  console.log(".env file updated");
84
92
  }));
85
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alex-c-line",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",