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 +1 -0
- package/loader/index.js +6 -5
- package/package.json +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +31 -0
package/cross/cross.js
CHANGED
package/loader/index.js
CHANGED
|
@@ -6,18 +6,19 @@ const { getElectronDir } = require('../ps');
|
|
|
6
6
|
|
|
7
7
|
// 加载单个文件(如果是函数,将被执行)
|
|
8
8
|
function loadFile(filepath, ...inject) {
|
|
9
|
-
|
|
9
|
+
let fullpath = filepath;
|
|
10
|
+
const isAbsolute = path.isAbsolute(fullpath);
|
|
10
11
|
if (!isAbsolute) {
|
|
11
|
-
|
|
12
|
+
fullpath = path.join(getElectronDir(), fullpath);
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
if (!fs.existsSync(
|
|
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(
|
|
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
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
|
|