@node-red/nodes 3.1.8 → 3.1.10

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.
@@ -378,7 +378,7 @@
378
378
  return { id: id, label: RED.nodes.workspace(id).label } //flow id + name
379
379
  } else {
380
380
  const instanceNode = RED.nodes.node(id)
381
- const pathLabel = (instanceNode.name || RED.nodes.subflow(instanceNode.type.substring(8)).name)
381
+ const pathLabel = (instanceNode.name || RED.nodes.subflow(instanceNode.type.substring(8))?.name || instanceNode.type)
382
382
  return { id: id, label: pathLabel }
383
383
  }
384
384
  })
@@ -194,27 +194,46 @@
194
194
  nodeMap[node.links[i]].new = true;
195
195
  }
196
196
  }
197
- var n;
198
- for (var id in nodeMap) {
197
+
198
+ let editHistories = []
199
+ let n;
200
+ for (let id in nodeMap) {
199
201
  if (nodeMap.hasOwnProperty(id)) {
200
202
  n = RED.nodes.node(id);
201
203
  if (n) {
204
+ editHistories.push({
205
+ t:'edit',
206
+ node: n,
207
+ changes: {
208
+ links: [...n.links]
209
+ },
210
+ changed: n.changed
211
+ })
202
212
  if (nodeMap[id].old && !nodeMap[id].new) {
203
213
  // Removed id
204
214
  i = n.links.indexOf(node.id);
205
215
  if (i > -1) {
206
216
  n.links.splice(i,1);
217
+ n.changed = true
218
+ n.dirty = true
207
219
  }
208
220
  } else if (!nodeMap[id].old && nodeMap[id].new) {
209
221
  // Added id
210
222
  i = n.links.indexOf(id);
211
223
  if (i === -1) {
212
224
  n.links.push(node.id);
225
+ n.changed = true
226
+ n.dirty = true
213
227
  }
214
228
  }
215
229
  }
216
230
  }
217
231
  }
232
+ if (editHistories.length > 0) {
233
+ return {
234
+ history: editHistories
235
+ }
236
+ }
218
237
  }
219
238
 
220
239
  function onAdd() {
@@ -254,13 +273,14 @@
254
273
  onEditPrepare(this,"link out");
255
274
  },
256
275
  oneditsave: function() {
257
- onEditSave(this);
276
+ const result = onEditSave(this);
258
277
  // In case the name has changed, ensure any link call nodes on this
259
278
  // tab are redrawn with the updated name
260
279
  var localCallNodes = RED.nodes.filterNodes({z:RED.workspaces.active(), type:"link call"});
261
280
  localCallNodes.forEach(function(node) {
262
281
  node.dirty = true;
263
282
  });
283
+ return result
264
284
  },
265
285
  onadd: onAdd,
266
286
  oneditresize: resizeNodeList
@@ -329,7 +349,7 @@
329
349
  onEditPrepare(this,"link in");
330
350
  },
331
351
  oneditsave: function() {
332
- onEditSave(this);
352
+ return onEditSave(this);
333
353
  },
334
354
  oneditresize: resizeNodeList
335
355
  });
@@ -373,7 +393,7 @@
373
393
 
374
394
  },
375
395
  oneditsave: function() {
376
- onEditSave(this);
396
+ return onEditSave(this);
377
397
  },
378
398
  onadd: onAdd,
379
399
  oneditresize: resizeNodeList
@@ -374,7 +374,7 @@ module.exports = function(RED) {
374
374
  iniOpt.breakOnSigint = true;
375
375
  }
376
376
  }
377
- node.script = vm.createScript(functionText, createVMOpt(node, ""));
377
+ node.script = new vm.Script(functionText, createVMOpt(node, ""));
378
378
  if (node.fin && (node.fin !== "")) {
379
379
  var finText = `(function () {
380
380
  var node = {
@@ -438,10 +438,9 @@ module.exports = function(RED) {
438
438
 
439
439
  //store the error in msg to be used in flows
440
440
  msg.error = err;
441
-
442
- var line = 0;
443
- var errorMessage;
444
441
  if (stack.length > 0) {
442
+ let line = 0;
443
+ let errorMessage;
445
444
  while (line < stack.length && stack[line].indexOf("ReferenceError") !== 0) {
446
445
  line++;
447
446
  }
@@ -455,11 +454,13 @@ module.exports = function(RED) {
455
454
  errorMessage += " (line "+lineno+", col "+cha+")";
456
455
  }
457
456
  }
457
+ if (errorMessage) {
458
+ err.message = errorMessage
459
+ }
458
460
  }
459
- if (!errorMessage) {
460
- errorMessage = err.toString();
461
- }
462
- done(errorMessage);
461
+ // Pass the whole error object so any additional properties
462
+ // (such as cause) are preserved
463
+ done(err);
463
464
  }
464
465
  else if (typeof err === "string") {
465
466
  done(err);
@@ -20,6 +20,7 @@ module.exports = function(RED) {
20
20
  var exec = require('child_process').exec;
21
21
  var fs = require('fs');
22
22
  var isUtf8 = require('is-utf8');
23
+ const isWindows = process.platform === 'win32'
23
24
 
24
25
  function ExecNode(n) {
25
26
  RED.nodes.createNode(this,n);
@@ -85,9 +86,12 @@ module.exports = function(RED) {
85
86
  }
86
87
  });
87
88
  var cmd = arg.shift();
89
+ // Since 18.20.2/20.12.2, it is invalid to call spawn on Windows with a .bat/.cmd file
90
+ // without using shell: true.
91
+ const opts = isWindows ? { ...node.spawnOpt, shell: true } : node.spawnOpt
88
92
  /* istanbul ignore else */
89
93
  node.debug(cmd+" ["+arg+"]");
90
- child = spawn(cmd,arg,node.spawnOpt);
94
+ child = spawn(cmd,arg,opts);
91
95
  node.status({fill:"blue",shape:"dot",text:"pid:"+child.pid});
92
96
  var unknownCommand = (child.pid === undefined);
93
97
  if (node.timer !== 0) {
@@ -103,7 +103,7 @@
103
103
  <h4>Automatic mode</h4>
104
104
  <p>Automatic mode uses the <code>parts</code> property of incoming messages to
105
105
  determine how the sequence should be joined. This allows it to automatically
106
- reverse the action of a <b>split</b> node.
106
+ reverse the action of a <b>split</b> node.</p>
107
107
 
108
108
  <h4>Manual mode</h4>
109
109
  <p>When configured to join in manual mode, the node is able to join sequences
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/nodes",
3
- "version": "3.1.8",
3
+ "version": "3.1.10",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",