alex-c-line 1.3.2 → 1.3.4

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,21 +90,28 @@ 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 (leave value blank to delete property)").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
- if (value !== void 0) {
103
- currentEnvFileContents[key] = value;
106
+ if (newValue !== void 0) {
107
+ currentEnvFileContents[key] = newValue;
104
108
  } else {
105
109
  delete currentEnvFileContents[key];
106
110
  }
107
- yield (0, import_promises.writeFile)(import_path2.default.join(process.cwd(), ".env"), (0, import_dotenv_stringify.default)(currentEnvFileContents));
111
+ yield (0, import_promises.writeFile)(
112
+ import_path2.default.join(process.cwd(), file),
113
+ (0, import_dotenv_stringify.default)(currentEnvFileContents) + "\n"
114
+ );
108
115
  console.log(".env file updated");
109
116
  }));
110
117
  }
package/dist/index.js CHANGED
@@ -69,21 +69,28 @@ 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 (leave value blank to delete property)").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
- if (value !== void 0) {
82
- currentEnvFileContents[key] = value;
85
+ if (newValue !== void 0) {
86
+ currentEnvFileContents[key] = newValue;
83
87
  } else {
84
88
  delete currentEnvFileContents[key];
85
89
  }
86
- yield writeFile(path2.join(process.cwd(), ".env"), dotenvStringify(currentEnvFileContents));
90
+ yield writeFile(
91
+ path2.join(process.cwd(), file),
92
+ dotenvStringify(currentEnvFileContents) + "\n"
93
+ );
87
94
  console.log(".env file updated");
88
95
  }));
89
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alex-c-line",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",