ee-bin 4.0.1 → 4.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-bin",
3
- "version": "4.0.1",
3
+ "version": "4.1.1",
4
4
  "description": "ee bin",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -2,9 +2,10 @@
2
2
 
3
3
  const path = require('path');
4
4
  const fs = require('fs');
5
+ const fsPro = require('fs-extra');
5
6
  const crypto = require('crypto')
6
7
  const chalk = require('chalk');
7
- const { loadConfig, rm, getPackage, writeJsonSync } = require('../lib/utils');
8
+ const { loadConfig, getPackage, writeJsonSync } = require('../lib/utils');
8
9
  const admZip = require('adm-zip')
9
10
 
10
11
  /**
@@ -14,6 +15,16 @@ const admZip = require('adm-zip')
14
15
 
15
16
  class IncrUpdater {
16
17
 
18
+ constructor() {
19
+ this.tmpAppDirs = [
20
+ 'mac',
21
+ 'mac-arm64',
22
+ 'win-unpacked',
23
+ 'win-ia32-unpacked',
24
+ 'linux-unpacked'
25
+ ];
26
+ }
27
+
17
28
  /**
18
29
  * 执行
19
30
  */
@@ -50,14 +61,6 @@ class IncrUpdater {
50
61
  let asarFilePath = "";
51
62
  if (asarFile) {
52
63
  asarFilePath = path.normalize(path.join(homeDir, asarFile));
53
- } else if (Array.isArray(cfg.asarFile)) {
54
- // 检查文件列表,如果存在就跳出
55
- for (const filep of cfg.asarFile) {
56
- asarFilePath = path.normalize(path.join(homeDir, filep));
57
- if (fs.existsSync(asarFilePath)) {
58
- break;
59
- }
60
- }
61
64
  } else {
62
65
  asarFilePath = path.normalize(path.join(homeDir, cfg.asarFile));
63
66
  }
@@ -119,11 +122,10 @@ class IncrUpdater {
119
122
 
120
123
  // 删除缓存文件,防止生成的 zip 是旧版本
121
124
  if (cfg.cleanCache) {
122
- rm(path.join(homeDir, cfg.output.directory, 'mac'));
123
- rm(path.join(homeDir, cfg.output.directory, 'mac-arm64'));
124
- rm(path.join(homeDir, cfg.output.directory, 'win-unpacked'));
125
- rm(path.join(homeDir, cfg.output.directory, 'win-ia32-unpacked'));
126
- rm(path.join(homeDir, cfg.output.directory, 'linux-unpacked'));
125
+ this.tmpAppDirs.forEach(dir => {
126
+ const dirPath = path.join(homeDir, cfg.output.directory, dir);
127
+ fsPro.removeSync(dirPath);
128
+ });
127
129
  }
128
130
  }
129
131
 
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