# Diff/merge tool for function nodes code

**URL:** <https://discourse.nodered.org/t/diff-merge-tool-for-function-nodes-code/44021>\
**Category:** Feature Requests\
**Created:** [12 April 2021 08:53 UTC](https://discourse.nodered.org/t/diff-merge-tool-for-function-nodes-code/44021 "2021-04-12T08:53:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aschena](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aschena/32/40153_2.png) [@aschena](https://discourse.nodered.org/u/aschena)\
**Post date:** [12 April 2021 08:53 UTC](https://discourse.nodered.org/t/diff-merge-tool-for-function-nodes-code/44021/1 "2021-04-12T08:53:20Z")

</div>

Hello,  
I often have to compare different function nodes (within the same tab or different tabs) in order to find their differences out, and transfer some of the differences from one to the other.  
Actually the easiest way to do this is to copy/paste their code in an external diff tool, find the differences, manually merge them by copying pieces to a final version, and finally paste the result back into the flow.  
I think that an integrated tool to do so would help a lot and save much time.  
I'm thinking about a classic diff/merge UI, with side-by-side contents, visually highlighted differences (added lines in green, removed lines in red, changed lines in blue or another color), and commands to transfer changes right-to-left or left-to-right.

Thanks for your attention!  
Best regards,  
Alberto Schena

---

<div class="post-metadata">

**Author:** ![chrisn-au](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chrisn-au/32/25504_2.png) [@chrisn-au](https://discourse.nodered.org/u/chrisn-au)\
**Post date:** [12 April 2021 09:32 UTC](https://discourse.nodered.org/t/diff-merge-tool-for-function-nodes-code/44021/2 "2021-04-12T09:32:46Z")

</div>

Heh,

Sounds like an interesting problem a lot of the capability is already there. You could piece a lot of the bits together yourself,

The Admin API has the ability to extract details from a node including a function node. you could extract the code form the node, save it to a file, do the same with another node and save to a file.

Open the files in Visual studio code and do a compare and modify. Save the new file to a file name, load the file back into node red with another flow and update the function node.

I would experiment getting the bits to work. You will be surpised at how far you can get with the existing, stuff

Will be interested to see how you go

Visual studio code has a very good file compare capability. Using the function node to extract the the relevant

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 April 2021 09:47 UTC](https://discourse.nodered.org/t/diff-merge-tool-for-function-nodes-code/44021/3 "2021-04-12T09:47:56Z")

</div>

Hi.

Once we have access to monaco (the same code editor used by VSCode) in the editor, it will be fairly trivial to achieve an inline diff. Obviously implementation and effort vs benefit would need to be assessed.

NOTE: I'm not sure if ACE has this capability

Example of [inline diff in monaco](https://microsoft.github.io/monaco-editor/playground.html#creating-the-diffeditor-navigating-a-diff)

The current state of monaco for node-red is that it is generally excepted by Nick as a possible V2 feature (obviously many details still to be ratified). The main thread is [here](https://discourse.nodered.org/t/using-monaco-editor-monaco-branch-now-in-fork-pr-2798/26561/98) if you are interested.

The monaco branch It is currently up to date with current dev branch (as of yesterday anyhow - things move fast & I do have a day job)

---

<div class="post-metadata">

**Author:** ![chrisn-au](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chrisn-au/32/25504_2.png) [@chrisn-au](https://discourse.nodered.org/u/chrisn-au)\
**Post date:** [12 April 2021 10:58 UTC](https://discourse.nodered.org/t/diff-merge-tool-for-function-nodes-code/44021/4 "2021-04-12T10:58:20Z")

</div>

I have just read the thread on Monaco - looks very cool agree that will go a long way to solving the problem

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 April 2021 19:43 UTC](https://discourse.nodered.org/t/diff-merge-tool-for-function-nodes-code/44021/5 "2021-04-28T19:43:10Z")

</div>

Hey @aschena while developing monaco for node-red I decided to have a play.

Turns out to be quite easy to integrate diff functionality...

 ![oLc6Sx2E01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/4/9498c047878034b98afeb4792061131f871ab26f.gif)

It is really basic and only a demo at this point but could some day end up in v2.x.x 🙂

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 April 2021 21:35 UTC](https://discourse.nodered.org/t/diff-merge-tool-for-function-nodes-code/44021/6 "2021-04-28T21:35:27Z")

</div>

You _tease_ Steve! 🤣

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 June 2021 21:36 UTC](https://discourse.nodered.org/t/diff-merge-tool-for-function-nodes-code/44021/7 "2021-06-27T21:36:07Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
