<@UL1A5BA2X> hey there, thanks for the response on...
# javascript
l
@Big Chungus hey there, thanks for the response on Github. Here is my repository. The issue is, as described, that the code in main() is executed twice which is weird. Here is the link to repo and the code is on develop branch https://github.com/LukasAnda/Transkribe
b
That's quite a big repo. Could you point me to the file that contains the
main()
? Also Libraries should not have a main in the first place, so maybe you need to rethink your architecture?
l
The main point of this code is to have a common code for Kotlin command line app I can compile for native binaries along with publishing on NPM and brew to name a few. As for your question, the code for main() is in commonMain in src, the js that is being executed is in bin/
b
Can I get a link to main()? Can't find it
l
and in src/jsMain/cli/ you can find the wrapper for JS executable which I was hoping would export the function so it would not be run when I require it
b
Ok, first off, just rename main() in js to anything else. That way it will not be executed.
Secondly, move main() out of commonMain, because your js version of cli is bootstrapped differently and cannot have a main (i.e. is used as a library that's consumed by ./bin/transkribe as opposed to standalone executable)
in short - main() method is executed on import in JS, regardless if it's compiled as a library or executable
Hope that makes sense
l
Okay, so I can just rename the method to for example transkribe(args: Array<String>) ?
b
Yes. Also you seem to be confused aboud what main() is, since your commonMain that you've linked does NOT have a main() method
l
yes, sorry for that. I am trying to explore it as I am going through the code. But it works now so thanks.
b
Glad to hear that. Good luck!
l
Thank you, I will share my progress later 🙂
👍 1