ee-bin 4.1.0 → 4.1.2

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/tools/serve.js +27 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-bin",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "description": "ee bin",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,7 +20,7 @@
20
20
  "config-file-ts": "^0.2.8-rc1",
21
21
  "cross-spawn": "^7.0.3",
22
22
  "debug": "^4.4.0",
23
- "esbuild": "0.24.2",
23
+ "esbuild": "^0.21.5",
24
24
  "fs-extra": "^10.0.0",
25
25
  "globby": "^10.0.0",
26
26
  "is-type-of": "^1.2.1",
package/tools/serve.js CHANGED
@@ -47,34 +47,39 @@ class ServeProcess {
47
47
  // watche electron main code
48
48
  const electronConfig = binCmdConfig.electron;
49
49
  if (electronConfig.watch) {
50
+ let debounceTimer = null;
50
51
  const cmd = 'electron';
51
52
  const watcher = chokidar.watch([this.electronDir], {
52
53
  persistent: true
53
54
  });
54
55
  watcher.on('change', async (f) => {
55
56
  console.log(chalk.blue('[ee-bin] [dev] ') + `File ${f} has been changed`);
56
- console.log(chalk.blue('[ee-bin] [dev] ') + `Restart ${cmd}`);
57
-
58
- // rebuild code
59
- this.bundle(binCfg.build.electron);
60
- let subPorcess = this.execProcess[cmd];
61
- kill(subPorcess.pid, 'SIGKILL', (err) => {
62
- if (err) {
63
- console.log(chalk.red('[ee-bin] [dev] ') + `Restart failed, error: ${err}`);
64
- process.exit(-1);
65
- }
66
- })
67
- delete this.execProcess[cmd];
68
-
69
- // restart electron command
70
- setTimeout(() => {
71
- let onlyElectronOpt = {
72
- binCmd,
73
- binCmdConfig,
74
- command: cmd,
75
- }
76
- this.multiExec(onlyElectronOpt);
77
- }, electronConfig.delay);
57
+
58
+ // 防抖
59
+ if (debounceTimer) {
60
+ clearTimeout(debounceTimer);
61
+ }
62
+ debounceTimer = setTimeout(async () => {
63
+ // rebuild code
64
+ console.log(chalk.blue('[ee-bin] [dev] ') + `Restart ${cmd}`);
65
+ this.bundle(binCfg.build.electron);
66
+ let subPorcess = this.execProcess[cmd];
67
+ kill(subPorcess.pid, 'SIGKILL', (err) => {
68
+ if (err) {
69
+ console.log(chalk.red('[ee-bin] [dev] ') + `Restart failed, error: ${err}`);
70
+ process.exit(-1);
71
+ }
72
+ delete this.execProcess[cmd];
73
+
74
+ // restart electron command
75
+ let onlyElectronOpt = {
76
+ binCmd,
77
+ binCmdConfig,
78
+ command: cmd,
79
+ }
80
+ this.multiExec(onlyElectronOpt);
81
+ })
82
+ }, electronConfig.delay);
78
83
  });
79
84
  }
80
85