@collectui/cli 0.2.26 → 0.2.27
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/package.json +1 -1
- package/src/project.mjs +5 -1
package/package.json
CHANGED
package/src/project.mjs
CHANGED
|
@@ -115,7 +115,11 @@ export function mergeRegistries(components, units, { me, registryBase, force = f
|
|
|
115
115
|
|
|
116
116
|
/** 文本级 .env 合并:保留注释/顺序,不覆盖用户已有的不同值(除非 --force)。 */
|
|
117
117
|
export function mergeEnvText(text, envSpecs, { cliKey, force = false }) {
|
|
118
|
-
|
|
118
|
+
let lines = (text ?? "").split(/\r?\n/);
|
|
119
|
+
// 剥掉尾部空串(结尾换行的 split 产物 / 空文件):追加行紧跟已有内容,
|
|
120
|
+
// 新建文件不产生前导空行(2026-12-06 用户反馈:key 行上边莫名多一个空行)
|
|
121
|
+
if (lines.length === 1 && lines[0] === "") lines = [];
|
|
122
|
+
else if (lines.length && lines[lines.length - 1] === "") lines.pop();
|
|
119
123
|
const existing = new Map();
|
|
120
124
|
for (const [index, line] of lines.entries()) {
|
|
121
125
|
const m = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)$/.exec(line);
|