cloving 0.3.8 → 0.3.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloving",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "packageManager": "yarn@1.22.22",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -226,22 +226,25 @@ exports.extractBlock = extractBlock;
226
226
  * Each block contains information about file paths, current content, and new content.
227
227
  *
228
228
  * The blocks are defined by specific delimiters:
229
+ * - Setup: '```lang'
229
230
  * - Start: '<<<<<<< CURRENT'
230
231
  * - Divider: '======='
231
232
  * - End: '>>>>>>> NEW'
233
+ * - Finish: '```'
232
234
  *
233
235
  * @param {string} [input] - The input string containing CURRENT/NEW blocks.
234
236
  * @returns {CurrentNewBlock[]} An array of CurrentNewBlock objects, each representing a parsed block.
235
237
  * If the input is undefined or empty, an empty array is returned.
236
238
  *
237
239
  * @example
238
- * const input = `
240
+ * const input = "
241
+ * ```typescript
239
242
  * <<<<<<< CURRENT path/to/file.ts
240
243
  * const oldCode = 'old'
241
244
  * =======
242
245
  * const newCode = 'new'
243
246
  * >>>>>>> NEW
244
- * `
247
+ * ```"
245
248
  * const blocks = extractCurrentNewBlocks(input)
246
249
  * // blocks will contain one CurrentNewBlock object with the parsed information
247
250
  */
@@ -312,6 +315,10 @@ const searchReplaceString = (currentContent, block) => {
312
315
  if (block.currentContent.trim() === '') {
313
316
  return block.newContent;
314
317
  }
318
+ // check if you can replace the entire block without changing indentation
319
+ if (currentContent.includes(block.currentContent)) {
320
+ return currentContent.replace(block.currentContent, block.newContent);
321
+ }
315
322
  // 2) split currentContent and block.currentContent into new lines and trim() all the lines, then put back the new lines
316
323
  const currentLines = currentContent.split('\n').map((line) => line.trim());
317
324
  const blockLines = block.currentContent.split('\n').map((line) => line.trim());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloving",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "packageManager": "yarn@1.22.22",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",