mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Move hooks to util package
This commit is contained in:
parent
c021b4c368
commit
ed351eee54
@ -19,7 +19,7 @@ var redUtil = require("@node-red/util").util;
|
|||||||
const events = require("@node-red/util").events;
|
const events = require("@node-red/util").events;
|
||||||
var flowUtil = require("./util");
|
var flowUtil = require("./util");
|
||||||
const context = require('../nodes/context');
|
const context = require('../nodes/context');
|
||||||
const hooks = require("../hooks");
|
const hooks = require("@node-red/util").hooks;
|
||||||
|
|
||||||
var Subflow;
|
var Subflow;
|
||||||
var Log;
|
var Log;
|
||||||
|
@ -20,7 +20,6 @@ var redNodes = require("./nodes");
|
|||||||
var flows = require("./flows");
|
var flows = require("./flows");
|
||||||
var storage = require("./storage");
|
var storage = require("./storage");
|
||||||
var library = require("./library");
|
var library = require("./library");
|
||||||
var hooks = require("./hooks");
|
|
||||||
var plugins = require("./plugins");
|
var plugins = require("./plugins");
|
||||||
var settings = require("./settings");
|
var settings = require("./settings");
|
||||||
|
|
||||||
@ -29,7 +28,7 @@ var path = require('path');
|
|||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var os = require("os");
|
var os = require("os");
|
||||||
|
|
||||||
const {log,i18n,events,exec,util} = require("@node-red/util");
|
const {log,i18n,events,exec,util,hooks} = require("@node-red/util");
|
||||||
|
|
||||||
var runtimeMetricInterval = null;
|
var runtimeMetricInterval = null;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ var redUtil = require("@node-red/util").util;
|
|||||||
var Log = require("@node-red/util").log;
|
var Log = require("@node-red/util").log;
|
||||||
var context = require("./context");
|
var context = require("./context");
|
||||||
var flows = require("../flows");
|
var flows = require("../flows");
|
||||||
const hooks = require("../hooks");
|
const hooks = require("@node-red/util").hooks;
|
||||||
|
|
||||||
|
|
||||||
const NOOP_SEND = function() {}
|
const NOOP_SEND = function() {}
|
||||||
|
10
packages/node_modules/@node-red/util/index.js
vendored
10
packages/node_modules/@node-red/util/index.js
vendored
@ -19,6 +19,7 @@ const i18n = require("./lib/i18n");
|
|||||||
const util = require("./lib/util");
|
const util = require("./lib/util");
|
||||||
const events = require("./lib/events");
|
const events = require("./lib/events");
|
||||||
const exec = require("./lib/exec");
|
const exec = require("./lib/exec");
|
||||||
|
const hooks = require("./lib/hooks");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module provides common utilities for the Node-RED runtime and editor
|
* This module provides common utilities for the Node-RED runtime and editor
|
||||||
@ -69,5 +70,12 @@ module.exports = {
|
|||||||
* @mixes @node-red/util_exec
|
* @mixes @node-red/util_exec
|
||||||
* @memberof @node-red/util
|
* @memberof @node-red/util
|
||||||
*/
|
*/
|
||||||
exec: exec
|
exec: exec,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runtime hooks
|
||||||
|
* @mixes @node-red/util_hooks
|
||||||
|
* @memberof @node-red/util
|
||||||
|
*/
|
||||||
|
hooks: hooks
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const Log = require("@node-red/util").log;
|
const Log = require("./log.js");
|
||||||
|
|
||||||
const VALID_HOOKS = [
|
const VALID_HOOKS = [
|
||||||
// Message Routing Path
|
// Message Routing Path
|
||||||
@ -179,4 +179,4 @@ module.exports = {
|
|||||||
add,
|
add,
|
||||||
remove,
|
remove,
|
||||||
trigger
|
trigger
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
const should = require("should");
|
const should = require("should");
|
||||||
const NR_TEST_UTILS = require("nr-test-utils");
|
const NR_TEST_UTILS = require("nr-test-utils");
|
||||||
|
|
||||||
const hooks = NR_TEST_UTILS.require("@node-red/runtime/lib/hooks");
|
const hooks = NR_TEST_UTILS.require("@node-red/util/lib/hooks");
|
||||||
|
|
||||||
describe("runtime/hooks", function() {
|
describe("util/hooks", function() {
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
hooks.clear();
|
hooks.clear();
|
||||||
})
|
})
|
||||||
@ -81,7 +81,7 @@ describe("runtime/hooks", function() {
|
|||||||
hooks.has("onSend.A").should.be.false();
|
hooks.has("onSend.A").should.be.false();
|
||||||
hooks.has("onSend.B").should.be.false();
|
hooks.has("onSend.B").should.be.false();
|
||||||
hooks.has("onSend").should.be.false();
|
hooks.has("onSend").should.be.false();
|
||||||
|
|
||||||
done(err);
|
done(err);
|
||||||
} catch(err2) {
|
} catch(err2) {
|
||||||
done(err2);
|
done(err2);
|
Loading…
Reference in New Issue
Block a user