ee-core 2.8.0-beta.3 → 2.8.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.
- package/config/config.default.js +1 -1
- package/cross/index.js +0 -5
- package/cross/spawnProcess.js +19 -28
- package/package.json +1 -1
- package/utils/helper.js +0 -16
package/config/config.default.js
CHANGED
package/cross/index.js
CHANGED
|
@@ -74,13 +74,10 @@ const CrossLanguageService = {
|
|
|
74
74
|
|
|
75
75
|
const allConfig = Conf.all();
|
|
76
76
|
const defaultOpt = allConfig.cross[service] || {};
|
|
77
|
-
console.log("defaultOpt:", defaultOpt);
|
|
78
|
-
//const targetConf = Object.assign({}, defaultOpt, opt);
|
|
79
77
|
const targetConf = extend(true, {}, defaultOpt, opt);
|
|
80
78
|
if (Object.keys(targetConf).length == 0) {
|
|
81
79
|
throw new Error(`[ee-core] [cross] The service [${service}] config does not exit`);
|
|
82
80
|
}
|
|
83
|
-
console.log("targetConf:", targetConf);
|
|
84
81
|
|
|
85
82
|
// eventEmitter
|
|
86
83
|
this._initEventEmitter();
|
|
@@ -88,11 +85,9 @@ const CrossLanguageService = {
|
|
|
88
85
|
// format params
|
|
89
86
|
let tmpArgs = targetConf.args;
|
|
90
87
|
let confPort = parseInt(Helper.getValueFromArgv(tmpArgs, 'port'));
|
|
91
|
-
console.log("confPort1:", confPort);
|
|
92
88
|
if (confPort > 0) {
|
|
93
89
|
// 动态生成port,传入的端口必须为int
|
|
94
90
|
confPort = await GetPort({ port: confPort });
|
|
95
|
-
console.log("confPort2:", confPort);
|
|
96
91
|
// 替换port
|
|
97
92
|
targetConf.args = Helper.replaceArgsValue(tmpArgs, "port", String(confPort));
|
|
98
93
|
}
|
package/cross/spawnProcess.js
CHANGED
|
@@ -34,7 +34,6 @@ class SpawnProcess {
|
|
|
34
34
|
// Launch executable program
|
|
35
35
|
let cmdPath = '';
|
|
36
36
|
let cmdArgs = targetConf.args;
|
|
37
|
-
console.log("targetConf.args:", targetConf.args);
|
|
38
37
|
let execDir = Ps.getExtraResourcesDir();
|
|
39
38
|
let standardOutput = ['inherit', 'inherit', 'inherit', 'ipc'];
|
|
40
39
|
if (Ps.isPackaged()) {
|
|
@@ -44,8 +43,6 @@ class SpawnProcess {
|
|
|
44
43
|
const { cmd, directory } = targetConf;
|
|
45
44
|
// use cmd first
|
|
46
45
|
if (cmd) {
|
|
47
|
-
console.log("cmd:", cmd)
|
|
48
|
-
console.log("cmd isAbsolute :", path.isAbsolute(cmd))
|
|
49
46
|
if (!directory) {
|
|
50
47
|
throw new Error(`[ee-core] [cross] The config [directory] attribute does not exist`);
|
|
51
48
|
}
|
|
@@ -62,15 +59,10 @@ class SpawnProcess {
|
|
|
62
59
|
cmdPath += ".exe";
|
|
63
60
|
}
|
|
64
61
|
|
|
65
|
-
console.log("cmdPath:", cmdPath)
|
|
66
|
-
|
|
67
62
|
// executable program directory
|
|
68
|
-
console.log("directory:", directory)
|
|
69
63
|
if (directory && path.isAbsolute(directory)) {
|
|
70
|
-
console.log("directory isAbsolute :", path.isAbsolute(directory))
|
|
71
64
|
execDir = directory;
|
|
72
65
|
} else if (directory && !path.isAbsolute(directory)) {
|
|
73
|
-
console.log("directory isAbsolute :", path.isAbsolute(directory))
|
|
74
66
|
if (Ps.isDev()) {
|
|
75
67
|
execDir = path.join(Ps.getHomeDir(), directory);
|
|
76
68
|
} else {
|
|
@@ -79,7 +71,6 @@ class SpawnProcess {
|
|
|
79
71
|
} else {
|
|
80
72
|
execDir = Ps.getExtraResourcesDir();
|
|
81
73
|
}
|
|
82
|
-
console.log("execDir:", execDir)
|
|
83
74
|
|
|
84
75
|
Log.coreLogger.info(`[ee-core] [cross/run] cmd: ${cmdPath}, args: ${cmdArgs}`);
|
|
85
76
|
const coreProcess = crossSpawn(cmdPath, cmdArgs, {
|
|
@@ -121,25 +112,25 @@ class SpawnProcess {
|
|
|
121
112
|
}, timeout)
|
|
122
113
|
}
|
|
123
114
|
|
|
124
|
-
send(message) {
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
close() {
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
async sendByType(message, type) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
115
|
+
// send(message) {
|
|
116
|
+
// return this.sendByType(message, 'message');
|
|
117
|
+
// }
|
|
118
|
+
|
|
119
|
+
// close() {
|
|
120
|
+
// return this.sendByType('close', 'close');
|
|
121
|
+
// }
|
|
122
|
+
|
|
123
|
+
// async sendByType(message, type) {
|
|
124
|
+
// const msg = typeof message === 'string' ? message : JSON.stringify(message);
|
|
125
|
+
// const id = this._generateId();
|
|
126
|
+
|
|
127
|
+
// this.child.send({
|
|
128
|
+
// id,
|
|
129
|
+
// type,
|
|
130
|
+
// data: msg,
|
|
131
|
+
// });
|
|
132
|
+
// return;
|
|
133
|
+
// }
|
|
143
134
|
|
|
144
135
|
getUrl() {
|
|
145
136
|
const ssl = Helper.getValueFromArgv(this.config.args, 'ssl');
|
package/package.json
CHANGED
package/utils/helper.js
CHANGED
|
@@ -182,9 +182,7 @@ exports.replaceArgsValue = function(argv, key, value) {
|
|
|
182
182
|
let pos = item.indexOf(key);
|
|
183
183
|
if (pos !== -1) {
|
|
184
184
|
pos = pos + key.length;
|
|
185
|
-
console.log("pos2:", pos)
|
|
186
185
|
let tmpStr = item.substring(0, pos);
|
|
187
|
-
console.log("tmpStr:", tmpStr)
|
|
188
186
|
argv[i] = tmpStr + value;
|
|
189
187
|
break;
|
|
190
188
|
}
|
|
@@ -193,18 +191,6 @@ exports.replaceArgsValue = function(argv, key, value) {
|
|
|
193
191
|
return argv;
|
|
194
192
|
};
|
|
195
193
|
|
|
196
|
-
// exports.replaceValue = function(arr, key, value) {
|
|
197
|
-
// arr = arr.map(item => {
|
|
198
|
-
// if (item.startsWith(key)) {
|
|
199
|
-
// let newItem = key + value;
|
|
200
|
-
// return newItem;
|
|
201
|
-
// } else {
|
|
202
|
-
// return item;
|
|
203
|
-
// }
|
|
204
|
-
// });
|
|
205
|
-
// return arr;
|
|
206
|
-
// };
|
|
207
|
-
|
|
208
194
|
exports.getValueFromArgv = function(argv, key) {
|
|
209
195
|
const argvObj = Pargv(argv);
|
|
210
196
|
if (argvObj.hasOwnProperty(key)) {
|
|
@@ -219,9 +205,7 @@ exports.getValueFromArgv = function(argv, key) {
|
|
|
219
205
|
let pos = item.indexOf(key);
|
|
220
206
|
if (pos !== -1) {
|
|
221
207
|
pos = pos + key.length;
|
|
222
|
-
console.log("pos2:", pos)
|
|
223
208
|
value = item.substring(pos);
|
|
224
|
-
console.log("value:", value)
|
|
225
209
|
break;
|
|
226
210
|
}
|
|
227
211
|
}
|