Skip to content
Snippets Groups Projects
Commit 7d95251b authored by Robin Leber's avatar Robin Leber
Browse files

FIX: correct pipeBinding

parent 73473629
No related branches found
No related tags found
No related merge requests found
...@@ -39,12 +39,14 @@ export const handlePipeBinding = (pipeMapping, editor) => { ...@@ -39,12 +39,14 @@ export const handlePipeBinding = (pipeMapping, editor) => {
} else { } else {
let line = editor.state.doc.line(lineNumber); let line = editor.state.doc.line(lineNumber);
let position = line.from; let position = line.from;
let pipeNameUserGiven = pipe.pipeName;
let pipeNameDeklaration = transformPipeName(pipeNameUserGiven);
pipeNameUserGiven.replace(/\s+/g, "");
let insertCode = `\t\tconst ${pipeNameDeklaration} = "${pipeNameUserGiven}"\n\t\tawait channel.assertQueue(${pipeNameDeklaration}, {\n\t\t\tdurable: false\n\t\t});\n`;
let transaction = editor.state.update({ let transaction = editor.state.update({
changes: { changes: {
from: position, from: position,
insert: `\t\tconst ${pipe.pipeName.replace(/\s+/g, "")}Pipe = "${ insert: insertCode,
pipe.pipeName
}"\n`,
}, },
}); });
editor.dispatch(transaction); editor.dispatch(transaction);
...@@ -52,3 +54,10 @@ export const handlePipeBinding = (pipeMapping, editor) => { ...@@ -52,3 +54,10 @@ export const handlePipeBinding = (pipeMapping, editor) => {
} }
}); });
}; };
const transformPipeName = (str) => {
if (!str) return str;
const noSpacesStr = str.replace(/\s+/g, "");
if (noSpacesStr.length === 0) return "";
return noSpacesStr.charAt(0).toLowerCase() + noSpacesStr.slice(1);
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment