ClojureScript, NodeJS, and CLIs

278 views
Skip to first unread message

Jeremy Shoemaker

unread,
Apr 30, 2015, 11:25:47 AM4/30/15
to clojur...@googlegroups.com
Hi,

I started playing around with ClojureScript on NodeJS recently, and I was looking at making a lein template for making CLI tools that would work with npm so that the "binaries" end up in your path and can be used like any other NodeJS CLI tool.

I ran into trouble quickly because it seems when you compile using :target :nodejs, at runtime, it's expected that you set *main-cli-fn* to something.

In this case, I don't need that because I'm writing a wrapper JS file that runs the tool and is specified in the "bin" section of the package.json file that npm looks for.

It looks like it's trying to execute the main function as soon as I require the compiled JS file.

My question is, why is this behaviour forced as it is? It breaks what I'm trying to do, but worse it seems to preclude the possibility of writing a library that can be required into other NodeJS projects, even Javascript projects. It just seems to me that forcing this makes it harder to use ClojureScript with the rest of the Javascript NodeJS ecosystem. I don't see how I could write a ClojureScript NodeJS library that can be used by someone using Javascript on NodeJS.

Is there some way I can work around this limitation? If you need example code, I can provide some.

Thanks,
Jeremy

David Nolen

unread,
Apr 30, 2015, 12:46:28 PM4/30/15
to clojur...@googlegroups.com
It's the way it is because that's the way it was done nearly 4 years ago. If people want to see it improved submit patches.

David


--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to the Google Groups "ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Jeremy Shoemaker

unread,
Apr 30, 2015, 2:45:16 PM4/30/15
to clojur...@googlegroups.com
Okay, I'll take a look at it then. I just wanted to make sure I wasn't missing something in the design that required it.

Thanks,
Jeremy

David Nolen

unread,
Apr 30, 2015, 2:58:35 PM4/30/15
to clojur...@googlegroups.com
On Thu, Apr 30, 2015 at 2:45 PM, Jeremy Shoemaker <jer...@codingkoi.com> wrote:
Okay, I'll take a look at it then.  I just wanted to make sure I wasn't missing something in the design that required it.

Thanks,
Jeremy

I suspect most people targeting Node.js with ClojureScript are building applications so this hasn't been a big issue yet.

David 

Jeremy Shoemaker

unread,
May 1, 2015, 4:28:37 PM5/1/15
to clojur...@googlegroups.com
That's understandable. You build what you need when you need it.

I'm not sure what the contribution process is. From what I found, I thought it involved creating a ticket in the Clojure JIRA, but I'm having issues with it.

When I try to login, it throws an error saying that "user should not be null!". If I try to recover my password, it says I don't have an account with my email address, but if I try to create an account, it says one already exists with my email address. So, that's confusing. I use JIRA at work, so I know it can have weird issues at times.

Can I just submit a pull request on Github (after doing the whole contributor agreement thing)? Looks like it would be a one or two line code change, so it's not huge. Basically changing the conditional in nodejscli.cljs to not throw an error when *main-cli-fn* not set. It should probably only throw an error if it is set, but not set to a fn.

Thanks,
Jeremy

David Nolen

unread,
May 1, 2015, 4:35:21 PM5/1/15
to clojur...@googlegroups.com
Clojure projects do not take PRs. You need to submit a Clojure CA, then create a ticket and attach a patch to JIRA.

David


Thanks,
Jeremy

--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to the Google Groups "ClojureScript" group.

Daniel Compton

unread,
May 1, 2015, 11:35:52 PM5/1/15
to clojur...@googlegroups.com
Hi Jeremy

You can find more contributing info at http://clojure.org/contributing. If you're having issues with JIRA, then try asking Alex Miller on IRC, or Twitter @puredanger.

i - blis

unread,
May 4, 2015, 7:48:32 AM5/4/15
to clojur...@googlegroups.com
This is something I have been considering for a while. I ended up being not able to package the script and having to run it through a wrapper and symbolic link. Then, I abandoned the idea altogether.

Once you pushed the required changes, would you published your efforts and the said lein template somewhere? I (and probably others) would be pretty interested in smoothing a cljs nodejs scripting workflow.

Nice initiative.

Jeremy Shoemaker

unread,
May 6, 2015, 8:28:02 AM5/6/15
to clojur...@googlegroups.com
Sure!  As soon as my changes get merged in and released, I’ll get something up and reply here with the details.
-- 
Jeremy Shoemaker
--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/WH6zeE8yraA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages