Skip to content

Commit

Permalink
fix color issue
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Oct 19, 2020
1 parent 1723fb4 commit 34b25bc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/node-opcua-debug/source/index.ts
@@ -1,6 +1,7 @@
/**
* @module node-opcua-debug
*/
export { removeDecoration } from "./remove_decoration";
export { traceFromThisProjectOnly, displayTraceFromThisProjectOnly } from "./display_trace";
export { checkDebugFlag, setDebugFlag, make_debugLog, make_errorLog } from "./make_loggers";
export { makebuffer_from_trace, inlineText } from "./makebuffer_from_trace";
Expand Down
5 changes: 5 additions & 0 deletions packages/node-opcua-debug/source/remove_decoration.ts
@@ -0,0 +1,5 @@
const nonTextReg = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;

export function removeDecoration(str: string): string {
return str.replace(nonTextReg, "");
}
3 changes: 2 additions & 1 deletion packages/node-opcua-nodeid/package.json
Expand Up @@ -21,6 +21,7 @@
},
"devDependencies": {
"node-opcua-benchmarker": "2.17.0",
"node-opcua-debug": "2.20.0",
"should": "^13.2.3",
"source-map-support": "^0.5.19"
},
Expand All @@ -40,4 +41,4 @@
],
"homepage": "http://node-opcua.github.io/",
"gitHead": "e4d73afdfcccb3491423149d9b9785888f4ebb3c"
}
}
25 changes: 14 additions & 11 deletions packages/node-opcua-nodeid/test/test_nodeid.js
@@ -1,13 +1,16 @@
const coerceNodeId = require("..").coerceNodeId;
const resolveNodeId = require("..").resolveNodeId;
const makeNodeId = require("..").makeNodeId;
const NodeIdType = require("..").NodeIdType;
const NodeId = require("..").NodeId;
const sameNodeId = require("..").sameNodeId;
const {
coerceNodeId,
resolveNodeId,
makeNodeId,
NodeIdType,
NodeId,
sameNodeId
} = require("..");

const should = require("should");
const { assert } = require("node-opcua-assert");
const Benchmarker = require("node-opcua-benchmarker").Benchmarker;
const { Benchmarker } = require("node-opcua-benchmarker");
const { removeDecoration } = require("node-opcua-debug");

describe("testing NodeIds", function() {
it("should create a NUMERIC nodeID", function() {
Expand Down Expand Up @@ -55,14 +58,14 @@ describe("testing NodeIds", function() {
nodeId.toString().should.eql("ns=4;b=<null>");
});

it("should enriched NodeId#toString", () => {
it("NodeId#toString with addressSpace object (standard Nodes) 0", () => {
const nodeId = new NodeId(NodeIdType.NUMERIC, 2254, 0);
nodeId.toString({ addressSpace: "Hello" })
.should.eql("ns=0;i=2254 \u001b[32m\u001b[1mServer_ServerArray\u001b[22m\u001b[39m"
removeDecoration(nodeId.toString({ addressSpace: "Hello" }))
.should.eql("ns=0;i=2254 Server_ServerArray"
);
nodeId.displayText().should.eql("Server_ServerArray (ns=0;i=2254)");
});
it("should enriched NodeId#toString 2", () => {
it("NodeId#toString with addressSpace object (findNode) 2", () => {
const addressSpace = {
findNode() {
return { browseName: "Hello" }
Expand Down

0 comments on commit 34b25bc

Please sign in to comment.