git-watchtower 1.9.16 → 1.9.18

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.
@@ -2045,7 +2045,10 @@ function serveFile(res, filePath, logPath) {
2045
2045
  });
2046
2046
  }
2047
2047
 
2048
- const server = http.createServer((req, res) => {
2048
+ let server = null;
2049
+
2050
+ function createStaticServer() {
2051
+ return http.createServer((req, res) => {
2049
2052
  const url = new URL(req.url, `http://localhost:${PORT}`);
2050
2053
  let pathname = url.pathname;
2051
2054
  const logPath = pathname; // Keep original for logging
@@ -2084,7 +2087,8 @@ const server = http.createServer((req, res) => {
2084
2087
  }
2085
2088
 
2086
2089
  serveFile(res, filePath, logPath);
2087
- });
2090
+ });
2091
+ }
2088
2092
 
2089
2093
  // ============================================================================
2090
2094
  // File Watcher
@@ -2996,6 +3000,7 @@ async function start() {
2996
3000
  startServerProcess();
2997
3001
  } else {
2998
3002
  // Static mode
3003
+ server = createStaticServer();
2999
3004
  server.listen(PORT, () => {
3000
3005
  addLog(`Server started on http://localhost:${PORT}`, 'success');
3001
3006
  addLog(`Serving ${STATIC_DIR.replace(PROJECT_ROOT, '.')}`, 'info');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-watchtower",
3
- "version": "1.9.16",
3
+ "version": "1.9.18",
4
4
  "description": "Terminal-based Git branch monitor with activity sparklines and optional dev server with live reload",
5
5
  "main": "bin/git-watchtower.js",
6
6
  "bin": {
@@ -367,7 +367,7 @@ class Store {
367
367
  */
368
368
  addToHistory(from, to, maxEntries = 20) {
369
369
  const entry = { from, to, timestamp: new Date() };
370
- const switchHistory = [...this.state.switchHistory, entry].slice(-maxEntries);
370
+ const switchHistory = [entry, ...this.state.switchHistory].slice(0, maxEntries);
371
371
  this.setState({ switchHistory });
372
372
  }
373
373
 
@@ -377,14 +377,14 @@ class Store {
377
377
  */
378
378
  getLastSwitch() {
379
379
  const history = this.state.switchHistory;
380
- return history.length > 0 ? history[history.length - 1] : null;
380
+ return history.length > 0 ? history[0] : null;
381
381
  }
382
382
 
383
383
  /**
384
384
  * Remove the last switch from history (after undo)
385
385
  */
386
386
  popHistory() {
387
- const switchHistory = this.state.switchHistory.slice(0, -1);
387
+ const switchHistory = this.state.switchHistory.slice(1);
388
388
  this.setState({ switchHistory });
389
389
  }
390
390