pinokiod 2.15.43 → 2.15.45
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/kernel/api/index.js +1 -0
- package/kernel/shells.js +43 -0
- package/package.json +1 -1
package/kernel/api/index.js
CHANGED
package/kernel/shells.js
CHANGED
|
@@ -53,6 +53,40 @@ class Shells {
|
|
|
53
53
|
|
|
54
54
|
}
|
|
55
55
|
async launch(params, options, ondata) {
|
|
56
|
+
// if array, duplicate the action
|
|
57
|
+
if (Array.isArray(params.message)) {
|
|
58
|
+
let res
|
|
59
|
+
console.log("Message Array", params.message)
|
|
60
|
+
for(let i=0; i<params.message.length; i++) {
|
|
61
|
+
let message = params.message[i]
|
|
62
|
+
let params = Object.assign({}, params)
|
|
63
|
+
params.message = message
|
|
64
|
+
console.log("Launching Message", params)
|
|
65
|
+
res = await this._launch(params, options, ondata)
|
|
66
|
+
// if there's an error, trigger an error event
|
|
67
|
+
if (res.error) {
|
|
68
|
+
console.log("Error exists. Trigger an error", { res })
|
|
69
|
+
ondata({
|
|
70
|
+
id: res.id,
|
|
71
|
+
type: "error",
|
|
72
|
+
data: res.response,
|
|
73
|
+
event: res.error,
|
|
74
|
+
// rpc,
|
|
75
|
+
// rawrpc
|
|
76
|
+
})
|
|
77
|
+
// if there's an error, return immediately => so it will NOT go forward and stop the script
|
|
78
|
+
return res
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
console.log("Launch Message Array Finished", res)
|
|
82
|
+
return res
|
|
83
|
+
} else {
|
|
84
|
+
console.log("Single Message", params.message)
|
|
85
|
+
let res = await this._launch(params, options, ondata)
|
|
86
|
+
return res
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async _launch(params, options, ondata) {
|
|
56
90
|
// iterate through all the envs
|
|
57
91
|
params.env = this.kernel.bin.envs(params.env)
|
|
58
92
|
|
|
@@ -126,6 +160,8 @@ class Shells {
|
|
|
126
160
|
ondata(stream)
|
|
127
161
|
})
|
|
128
162
|
|
|
163
|
+
console.log(">>>>>> RESPONSE", response)
|
|
164
|
+
|
|
129
165
|
/*
|
|
130
166
|
{
|
|
131
167
|
method: "shell.run",
|
|
@@ -155,6 +191,7 @@ class Shells {
|
|
|
155
191
|
|
|
156
192
|
// 2. first find the `break: false` handlers and replace the patterns with blank => so they won't be matched in the next step
|
|
157
193
|
//let line = response.replaceAll(/[\r\n]/g, "")
|
|
194
|
+
console.log("checking breakpoints", breakPoints)
|
|
158
195
|
for(let handler of breakPoints) {
|
|
159
196
|
if (handler.event) {
|
|
160
197
|
let matches = /^\/(.+)\/([dgimsuy]*)$/gs.exec(handler.event)
|
|
@@ -170,6 +207,8 @@ class Shells {
|
|
|
170
207
|
}
|
|
171
208
|
}
|
|
172
209
|
|
|
210
|
+
console.log("Line before", line)
|
|
211
|
+
|
|
173
212
|
// 3. Now with all the `break: false` (ignored patterns) gone, look for the `break: true` patterns
|
|
174
213
|
for(let handler of breakPoints) {
|
|
175
214
|
if (handler.event) {
|
|
@@ -179,12 +218,16 @@ class Shells {
|
|
|
179
218
|
}
|
|
180
219
|
let re = new RegExp(matches[1], matches[2])
|
|
181
220
|
|
|
221
|
+
console.log("re", re)
|
|
222
|
+
|
|
182
223
|
// only the "break: true" ones
|
|
183
224
|
if (handler.break) {
|
|
225
|
+
console.log("checking break handler", handler)
|
|
184
226
|
|
|
185
227
|
let match;
|
|
186
228
|
// Keep executing the regex on the text until no more matches are found
|
|
187
229
|
while ((match = re.exec(line)) !== null) {
|
|
230
|
+
console.log("match found", match)
|
|
188
231
|
errors.add(match[0])
|
|
189
232
|
// errors.add(match.slice(1));
|
|
190
233
|
}
|