@node-red/util 2.1.4 → 2.2.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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright JS Foundation and other contributors, http://js.foundation
1
+ Copyright OpenJS Foundation and other contributors, https://openjsf.org/
2
2
 
3
3
  Apache License
4
4
  Version 2.0, January 2004
package/lib/events.js CHANGED
@@ -32,8 +32,14 @@ function wrapEventFunction(obj,func) {
32
32
  return function(eventName, listener) {
33
33
  if (deprecatedEvents.hasOwnProperty(eventName)) {
34
34
  const log = require("@node-red/util").log;
35
- const stack = (new Error().stack).split("\n")[2].split("(")[1].slice(0,-1);
36
- log.warn(`[RED.events] Deprecated use of "${eventName}" event from "${stack}". Use "${deprecatedEvents[eventName]}" instead.`)
35
+
36
+ const stack = (new Error().stack).split("\n");
37
+ let location = "(unknown)"
38
+ // See https://github.com/node-red/node-red/issues/3292
39
+ if (stack.length > 2) {
40
+ location = stack[2].split("(")[1].slice(0,-1);
41
+ }
42
+ log.warn(`[RED.events] Deprecated use of "${eventName}" event from "${location}". Use "${deprecatedEvents[eventName]}" instead.`)
37
43
  }
38
44
  return events["_"+func].call(events,eventName,listener)
39
45
  }
package/lib/util.js CHANGED
@@ -522,6 +522,17 @@ function setObjectProperty(msg,prop,value,createMissing) {
522
522
  * @return {String} value of env var
523
523
  */
524
524
  function getSetting(node, name, flow_) {
525
+ if (node) {
526
+ if (name === "NR_NODE_NAME") {
527
+ return node.name;
528
+ }
529
+ if (name === "NR_NODE_ID") {
530
+ return node.id;
531
+ }
532
+ if (name === "NR_NODE_PATH") {
533
+ return node._path;
534
+ }
535
+ }
525
536
  var flow = (flow_ ? flow_ : (node ? node._flow : null));
526
537
  if (flow) {
527
538
  if (node && node.g) {
@@ -686,7 +697,7 @@ function prepareJSONataExpression(value,node) {
686
697
  return moment(arg1, arg2, arg3, arg4);
687
698
  });
688
699
  expr.registerFunction('clone', cloneMessage, '<(oa)-:o>');
689
- expr._legacyMode = /(^|[^a-zA-Z0-9_'"])msg([^a-zA-Z0-9_'"]|$)/.test(value);
700
+ expr._legacyMode = /(^|[^a-zA-Z0-9_'".])msg([^a-zA-Z0-9_'"]|$)/.test(value);
690
701
  expr._node = node;
691
702
  return expr;
692
703
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/util",
3
- "version": "2.1.4",
3
+ "version": "2.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "fs-extra": "10.0.0",
19
- "i18next": "21.5.4",
19
+ "i18next": "21.6.10",
20
20
  "json-stringify-safe": "5.0.1",
21
21
  "jsonata": "1.8.5",
22
22
  "lodash.clonedeep": "^4.5.0",