I would like to compile all contracts in a folder at one go.

I tried "compile all": "docker run --rm -v \"$PWD\":\"$PWD\" -w \"$PWD\" ligolang/ligo:0.24.0 compile-contract contracts/*.ligo main > compiled/*.tz",

1 Answer 1



cd contracts
for i in *.ligo; do 
    docker run --rm -v \"$PWD\":\"$PWD\" -w \"$PWD\" \
        ligolang/ligo:0.24.0 compile-contract \ 
        contracts/$i main > compiled/$i.tz
  • thanks for your reply. Could you explain what you mean by for i in *.ls; Its not working and I'm trying to understand your code.
    – DottoreM
    Sep 20, 2021 at 12:27
  • Also, I am trying this out, as a script in my package.json
    – DottoreM
    Sep 20, 2021 at 12:28
  • i'm sorry, that was a type. it should be *.ligo of course. updating answer
    – arvidj
    Sep 21, 2021 at 7:04
  • I'm making some minor modifications so i can mark this as the answer: since $i is effectively the whole file name, you will end up with the extension printed twice. so for a given contract.ligo, $i.ligo will print contract.ligo.ligo.tz
    – DottoreM
    Sep 21, 2021 at 9:50
  • I also navigated inside the contracts folder to avoid having the path printed in the file name.
    – DottoreM
    Sep 21, 2021 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.