git-watchtower 1.10.19 → 1.10.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-watchtower",
3
- "version": "1.10.19",
3
+ "version": "1.10.20",
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": {
@@ -5,6 +5,7 @@
5
5
 
6
6
  const { spawn } = require('child_process');
7
7
  const { ServerError } = require('../utils/errors');
8
+ const { Mutex } = require('../utils/async');
8
9
 
9
10
  /**
10
11
  * @typedef {Object} ServerProcessState
@@ -90,6 +91,7 @@ class ProcessManager {
90
91
  this.crashed = false;
91
92
  this.logs = [];
92
93
  this.command = '';
94
+ this._restartMutex = new Mutex();
93
95
  }
94
96
 
95
97
  /**
@@ -283,13 +285,15 @@ class ProcessManager {
283
285
  * @returns {Promise<{success: boolean, error?: Error, pid?: number}>}
284
286
  */
285
287
  async restart() {
286
- const command = this.command;
287
- this.stop();
288
+ return this._restartMutex.withLock(async () => {
289
+ const command = this.command;
290
+ this.stop();
288
291
 
289
- // Wait before restarting
290
- await new Promise((resolve) => setTimeout(resolve, RESTART_DELAY));
292
+ // Wait before restarting
293
+ await new Promise((resolve) => setTimeout(resolve, RESTART_DELAY));
291
294
 
292
- return this.start(command);
295
+ return this.start(command);
296
+ });
293
297
  }
294
298
 
295
299
  /**