@theokit/sdk-tools 0.27.4-next.1 → 0.27.5

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.js CHANGED
@@ -31,11 +31,19 @@ var V4APatchError = class extends Error {
31
31
  this.name = "V4APatchError";
32
32
  }
33
33
  };
34
+ function missingBeginMessage(lines) {
35
+ const nearMiss = lines.find((l) => {
36
+ const t = l.trim();
37
+ return t !== BEGIN && t.startsWith(BEGIN);
38
+ });
39
+ if (nearMiss === void 0) return `Invalid patch: missing '${BEGIN}'`;
40
+ return `Invalid patch: the opening marker must be exactly '${BEGIN}', and this patch has '${nearMiss.trim()}'. Drop everything after '${BEGIN}' on that line \u2014 the trailing '***' belongs to no marker in this format.`;
41
+ }
34
42
  function parseV4A(patch) {
35
43
  const lines = patch.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
36
44
  let i = 0;
37
45
  while (i < lines.length && lines[i].trim() !== BEGIN) i++;
38
- if (i >= lines.length) throw new V4APatchError("Invalid patch: missing '*** Begin Patch'");
46
+ if (i >= lines.length) throw new V4APatchError(missingBeginMessage(lines));
39
47
  i++;
40
48
  const hunks = [];
41
49
  while (i < lines.length) {