ee-bin 4.0.0 → 4.1.0

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.
@@ -26,6 +26,7 @@ module.exports = {
26
26
  loadingPage: '/public/html/loading.html',
27
27
  watch: false,
28
28
  sync: false,
29
+ delay: 1000,
29
30
  },
30
31
  },
31
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-bin",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "ee bin",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,6 +26,7 @@
26
26
  "is-type-of": "^1.2.1",
27
27
  "javascript-obfuscator": "^4.0.2",
28
28
  "json5": "^2.2.3",
29
- "mkdirp": "^2.1.3"
29
+ "mkdirp": "^2.1.3",
30
+ "tree-kill": "^1.2.2"
30
31
  }
31
32
  }
@@ -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
@@ -9,6 +9,7 @@ const chalk = require('chalk');
9
9
  const crossSpawn = require('cross-spawn');
10
10
  const { buildSync } = require('esbuild');
11
11
  const chokidar = require('chokidar');
12
+ const kill = require('tree-kill');
12
13
 
13
14
  class ServeProcess {
14
15
 
@@ -57,16 +58,23 @@ class ServeProcess {
57
58
  // rebuild code
58
59
  this.bundle(binCfg.build.electron);
59
60
  let subPorcess = this.execProcess[cmd];
60
- subPorcess.kill();
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
+ })
61
67
  delete this.execProcess[cmd];
62
68
 
63
69
  // restart electron command
64
- let onlyElectronOpt = {
65
- binCmd,
66
- binCmdConfig,
67
- command: cmd,
68
- }
69
- this.multiExec(onlyElectronOpt);
70
+ setTimeout(() => {
71
+ let onlyElectronOpt = {
72
+ binCmd,
73
+ binCmdConfig,
74
+ command: cmd,
75
+ }
76
+ this.multiExec(onlyElectronOpt);
77
+ }, electronConfig.delay);
70
78
  });
71
79
  }
72
80