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 +12 -5
- package/dist/index.js +12 -5
- package/package.json +1 -1
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((
|
|
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(),
|
|
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 (
|
|
103
|
-
currentEnvFileContents[key] =
|
|
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)(
|
|
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((
|
|
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(),
|
|
80
|
+
yield readFile(path2.join(process.cwd(), file), "utf-8")
|
|
77
81
|
);
|
|
78
82
|
} catch (e) {
|
|
79
83
|
currentEnvFileContents = {};
|
|
80
84
|
}
|
|
81
|
-
if (
|
|
82
|
-
currentEnvFileContents[key] =
|
|
85
|
+
if (newValue !== void 0) {
|
|
86
|
+
currentEnvFileContents[key] = newValue;
|
|
83
87
|
} else {
|
|
84
88
|
delete currentEnvFileContents[key];
|
|
85
89
|
}
|
|
86
|
-
yield writeFile(
|
|
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
|
}
|