@paleo/workspace 0.15.0 → 0.15.1

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/cli.js CHANGED
@@ -288,7 +288,6 @@ export function printDevHelp() {
288
288
  "Commands:",
289
289
  " dev Start in the foreground, streaming logs from startup; CTRL+C stops it.",
290
290
  " If one is already running here, attach to its logs instead",
291
- " (CTRL+C then detaches, leaving it running).",
292
291
  " dev up Start in the background and return once ready.",
293
292
  " dev restart Stop this worktree's dev-server if running, then start in the background.",
294
293
  " dev down [--all] Stop this worktree's dev-server, or every dev-server with --all.",
@@ -269,14 +269,17 @@ function tailLogs(config, spawnPids, mode) {
269
269
  followLogFile(path, prefix, offset);
270
270
  }
271
271
  }
272
+ // Prints the last `lines` of the log, then returns the byte offset where `followLogFile` resumes
273
+ // (the file's current size). Reads raw bytes so the offset matches the file even if it holds
274
+ // invalid UTF-8, which a decoded string's byte length would not.
272
275
  function replayTail(path, prefix, lines) {
273
276
  if (!existsSync(path))
274
277
  return 0;
275
- const content = readFileSync(path, "utf8");
276
- const tail = lastLines(content, lines);
278
+ const buffer = readFileSync(path);
279
+ const tail = lastLines(buffer.toString("utf8"), lines);
277
280
  if (tail.length > 0)
278
281
  writeWithPrefix(tail.endsWith("\n") ? tail : `${tail}\n`, prefix);
279
- return Buffer.byteLength(content, "utf8");
282
+ return buffer.length;
280
283
  }
281
284
  function writeWithPrefix(text, prefix) {
282
285
  process.stdout.write(prefix === "" ? text : text.replace(/^(?=.)/gm, prefix));
package/dist/helpers.js CHANGED
@@ -22,6 +22,8 @@ export function extractHost(content, key, fallback = "localhost") {
22
22
  return m ? m[1] : fallback;
23
23
  }
24
24
  export function lastLines(content, count) {
25
+ if (count <= 0)
26
+ return "";
25
27
  return content.split("\n").slice(-count).join("\n");
26
28
  }
27
29
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paleo/workspace",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Run multiple git-worktree dev environments side by side.",
5
5
  "keywords": [
6
6
  "workspace",