ee-core 4.1.3 → 4.1.5

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/cross/cross.js CHANGED
@@ -106,6 +106,7 @@ class Cross {
106
106
 
107
107
  // 获取 proc
108
108
  getProcByName(name) {
109
+ // [todo] 如果有名字一样的服务,需要加 pid
109
110
  const pid = this.childrenMap[name];
110
111
  if (!pid) {
111
112
  throw new Error(`[ee-core] [cross] The process named [${name}] does not exit`);
package/loader/index.js CHANGED
@@ -6,18 +6,19 @@ const { getElectronDir } = require('../ps');
6
6
 
7
7
  // 加载单个文件(如果是函数,将被执行)
8
8
  function loadFile(filepath, ...inject) {
9
- const isAbsolute = path.isAbsolute(filepath);
9
+ let fullpath = filepath;
10
+ const isAbsolute = path.isAbsolute(fullpath);
10
11
  if (!isAbsolute) {
11
- filepath = path.join(getElectronDir(), filepath);
12
+ fullpath = path.join(getElectronDir(), fullpath);
12
13
  }
13
14
 
14
- filepath = filepath && resolveModule(filepath);
15
- if (!fs.existsSync(filepath)) {
15
+ fullpath = fullpath && resolveModule(fullpath);
16
+ if (!fs.existsSync(fullpath)) {
16
17
  let errorMsg = `[ee-core] [loader/index] loadFile ${filepath} does not exist`;
17
18
  throw new Error(errorMsg);
18
19
  }
19
20
 
20
- let ret = CoreUtils.loadFile(filepath);
21
+ let ret = CoreUtils.loadFile(fullpath);
21
22
  if (is.function(ret) && !is.class(ret) && !CoreUtils.isBytecodeClass(ret)) {
22
23
  ret = ret(...inject);
23
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-core",
3
- "version": "4.1.3",
3
+ "version": "4.1.5",
4
4
  "description": "ee core",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/utils/index.d.ts CHANGED
@@ -6,5 +6,6 @@ export declare function isWebProtocol(protocol: string): boolean;
6
6
  export declare function isJsProject(baseDir: string): boolean;
7
7
  export declare function machineIdSync(original: boolean): any;
8
8
  export declare function machineId(original: boolean): Promise<any>;
9
+ export declare function getPlatform(delimiter?: string, isDiffArch?: boolean): string;
9
10
  import is = require("./is");
10
11
  export { is };
package/utils/index.js CHANGED
@@ -109,6 +109,36 @@ function machineId(original) {
109
109
  });
110
110
  }
111
111
 
112
+ // get platform
113
+ // values: windows | windows_32 | windows_64 | macos_intel | macos_apple | linux
114
+ function getPlatform(delimiter = "_", isDiffArch = false) {
115
+ let osName = "";
116
+ if (is.windows()) {
117
+ osName = "windows";
118
+ if (isDiffArch) {
119
+ const arch = is.x64() ? "64" : "32";
120
+ osName += delimiter + arch;
121
+ }
122
+ } else if (is.macOS()) {
123
+ let isAppleSilicon = false;
124
+ const cpus = os.cpus();
125
+ for (let cpu of cpus) {
126
+ if (cpu.model.includes('Apple')) {
127
+ isAppleSilicon = true;
128
+ break;
129
+ }
130
+ }
131
+ const core = isAppleSilicon? "apple" : "intel";
132
+ osName = "macos" + delimiter + core;
133
+ } else if (is.linux()) {
134
+ osName = "linux";
135
+ }
136
+
137
+ return osName;
138
+ }
139
+
140
+
141
+
112
142
  function _isWindowsProcessMixedOrNativeArchitecture() {
113
143
  // detect if the node binary is the same arch as the Windows OS.
114
144
  // or if this is 32 bit node on 64 bit windows.
@@ -162,6 +192,7 @@ module.exports = {
162
192
  isJsProject,
163
193
  machineIdSync,
164
194
  machineId,
195
+ getPlatform,
165
196
  is
166
197
  }
167
198