Roald87 / roald87.github.io

Mostly cooking and coding in TwinCAT.
https://cookncode.com
MIT License
4 stars 2 forks source link

twincat/2022/04/14/pre-commit #24

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

No more formatting fights with pre-commits for TwinCAT

Earlier I talked about how you can do version control of your TwinCAT code with git. In this post, I want to show a very neat feature of git which I didn’t mention last time: pre-commits. You can use pre-commits to format, lint, or do static code analyses before you commit your code. Unfortunately, there is currently only one pre-commit for structured text files. But, you can also use pre-commits for markdown, html, or javascript files.

https://cookncode.com/twincat/2022/04/14/pre-commit.html

HolgerJeromin commented 2 years ago

Regarding to prettier you can tell it what parser to use for an unknown file: https://prettier.io/docs/en/configuration.html#configuration-overrides Even if this a bit cumbersome because of: https://github.com/prettier/prettier/issues/11141 But if you call prettier . ./**/*.theme this works. Edit 2023-12: The bug was fixed.


    "prettier": {
        "overrides": [
            {
                "files": "*.theme",
                "options": {
                    "parser": "json"
                }
            }
        ]
    },
Roald87 commented 2 years ago

@HolgerJeromin Thanks for the tip! I'll try it out.

larsrod81 commented 2 years ago

Nice job with the pre-commits! Do you have any experience / tips regarding pre-build scripts in Twincat XAE?

Roald87 commented 2 years ago

@larsrod81 glad you like it. I did use post build commands for a project in the past to generate html pages from markdown files. What would you like to do?

larsrod81 commented 1 year ago

Hi, I was planning to use post build command for extracting git info and use this for version info in the PLC. Main problem is that any "Execute" command in Twincat Deployment triggers the windows UAC dialog to pop up and require confirmation. Did you experience the same when generating html pages?

rruiter87 commented 1 year ago

@larsrod81 No I don't think so. We just did start [filename.exe] in the pre-build commands of the HMI project. I haven't used the Plc Project > Deployment functionality.