File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -492,7 +492,7 @@ TCVB 格式规范:
4924922. **创建操作(CREATE)**:
493493 - 创建一个新文件,后面直接给全文代码。
494494 - 新文件的全部内容应完整写入代码块中。
495- - 如果文件已经存在,应该有GLOBAL-REPLACE来插入,而不是用CREATE
495+ - 如果文件已经存在,应该有GLOBAL-REPLACE来插入,而不是用CREATE。如果是已有的文件,会直接把内容插入末尾。
496496
497497 示例:
498498 ## OPERATION:CREATE
@@ -637,12 +637,11 @@ export function mergeCvb(baseCvb: Cvb, tcvb: TCVB): Cvb {
637637 strContent = applyGlobalReplace ( strContent , op ) ;
638638 } else if ( op instanceof CreateOperation ) {
639639 if ( mapMergedFiles . has ( strFilePath ) ) {
640- throw new Error (
641- `${ strFilePath } 已经存在,不可以使用 ## OPERATION:CREATE`
642- ) ;
640+ strContent = applyInsertTail ( strContent , op ) ;
641+ }
642+ else {
643+ strContent = op . m_strContent ;
643644 }
644- // CREATE 操作:直接以新内容覆盖原有内容
645- strContent = op . m_strContent ;
646645 }
647646 }
648647 mapMergedFiles . set ( strFilePath , strContent ) ;
@@ -840,6 +839,13 @@ export function applyGlobalReplace(
840839 }
841840}
842841
842+ export function applyInsertTail (
843+ strContent : string ,
844+ op : CreateOperation ) {
845+ strContent += "\n" + op . m_strContent ;
846+ return strContent ;
847+ }
848+
843849// 根据前锚点、内容、后锚点构建正则表达式(dotall 模式)
844850function buildPattern (
845851 strBefore : string ,
You can’t perform that action at this time.
0 commit comments