@bigbinary/neeto-commons-frontend 4.13.62 → 4.13.63

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.
@@ -4,6 +4,10 @@ const { watch } = require("chokidar");
4
4
 
5
5
  const nanoDevelopmentPlugin = () => {
6
6
  let restartTimeout;
7
+ let watcher;
8
+ let restartInProgress = false;
9
+ let restartAgain = false;
10
+
7
11
  const isWatchMode = process.env.WATCH_MODE === "true";
8
12
 
9
13
  return {
@@ -15,7 +19,14 @@ const nanoDevelopmentPlugin = () => {
15
19
  "@bigbinary"
16
20
  );
17
21
 
18
- watch(bigBinaryPackagesDir, { ignoreInitial: true })
22
+ server.httpServer?.on("close", () => {
23
+ if (!watcher) return;
24
+
25
+ watcher.close();
26
+ watcher = null;
27
+ });
28
+
29
+ watcher = watch(bigBinaryPackagesDir, { ignoreInitial: true })
19
30
  .on("add", restartServer)
20
31
  .on("change", restartServer)
21
32
  .on("error", error =>
@@ -27,14 +38,32 @@ const nanoDevelopmentPlugin = () => {
27
38
  if (isWatchMode && !filePath.endsWith(".ready")) return;
28
39
 
29
40
  clearTimeout(restartTimeout);
30
- restartTimeout = setTimeout(async () => {
31
- try {
32
- await server.restart(true);
33
- } catch (error) {
34
- // eslint-disable-next-line no-console
35
- console.error(`[nano-development-plugin] restart error: ${error}`);
41
+ restartTimeout = setTimeout(() => {
42
+ if (restartInProgress) {
43
+ restartAgain = true;
44
+ } else {
45
+ doRestart();
36
46
  }
37
- }, 300);
47
+ }, 1000);
48
+ }
49
+
50
+ async function doRestart() {
51
+ restartInProgress = true;
52
+ try {
53
+ await server.restart(true);
54
+ } catch (error) {
55
+ // eslint-disable-next-line no-console
56
+ console.error(`[nano-development-plugin] restart error: ${error}`);
57
+ } finally {
58
+ setTimeout(() => {
59
+ restartInProgress = false;
60
+
61
+ if (restartAgain) {
62
+ restartAgain = false;
63
+ doRestart();
64
+ }
65
+ }, 1000);
66
+ }
38
67
  }
39
68
  },
40
69
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "4.13.62",
3
+ "version": "4.13.63",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",