Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Make sure the files are joined in alphabetical order for wildcard patterns #2673

Closed
zhanzhenzhen opened this Issue Jan 17, 2013 · 7 comments

Comments

Projects
None yet
5 participants
Contributor

zhanzhenzhen commented Jan 17, 2013

I think compiler should add some functions to make sure the files are joined alphabetically for wildcard patterns. For example, if I use:
--join client.js --compile client__.coffee
on my Ubuntu they are actually alphabetically sorted, but it seems I can't rely on it for all platforms.
Another suggestion is: Consider this option:
--join client.js --compile shared__.coffee client__.coffee
If there are no shared__.coffee files, it will result in an error. But I think it should still continue to compile the client_*.coffee files.

Those expansions come from your shell actually, that's why they differ across platforms. There's nothing node/coffee can really do about them.

Contributor

epidemian commented Jan 17, 2013

Yeap, this is no Coffee's fault. To solve both of those problems, you can use ls to list your arguments. It will sort the files alphabetically by default and will also not list non-existent files, just print an error to stderr in those cases (if you pass bla* to a command and no files match with that pattern, the command will receive bla* as a string, that's probably why the compiler was complaining):

coffee --join client.js --compile $(ls shared_*.coffee client_*.coffee)
Contributor

zhanzhenzhen commented Jan 17, 2013

But what about on Windows? One benifit of CoffeeScript commands is that they can be the same on both Linux and Windows. Can't just add a simple "sort file names" function to the compiler to ensure that on all platforms they are compiled in the same order using the same command? Why do we have to rely on the OS to achieve this? I know it's just a small question. I can use many workarounds. I just hope the compiler to be "perfect" because CoffeeScript is already a perfect language to me.

Contributor

epidemian commented Jan 17, 2013

I just hope the compiler to be "perfect" because CoffeeScript is already a perfect language to me.

Ho, i'd be so proud in Jeremy's shoes. I hope you don't come across some of the parsing issues hehe.

Anyway, the thing is that it's not as easy as just sorting the files alphabetically in the compiler. The order in which you pass the files to coffee is important. Suppose that i have two files: utils.coffee and app.coffee, and i need that utils.coffee is run before app.coffee (because app.coffee assumes some things already defined from utils.coffee). Then id' call:

coffee --join script.js --compile utils.coffee app.coffee

This is the current behavior, and i think it's pretty reasonable. If i want the files to be joined in a different order, i'd just change the order of the parameters and that's all.

Besides, it's not that the coffee compiler is behaving differently in different platforms in this case. It's that you're calling the coffee compiler differently in different platforms.

Collaborator

vendethiel commented Jan 17, 2013

if you're on windows then install cygwin or something :D else you're gonna have a bad time (well not using it myself but I'm using some build tools so yeah)

Contributor

zhanzhenzhen commented Jan 23, 2013

hi demian,
i just mean we should do it for a single pattern, not for all patterns.
In your example there are two patterns: coffee --join script.js --compile utils.coffee app.coffee
yes utils.coffee should be compiled before app.coffee, but if it's:
coffee --join script.js --compile utils.coffee client.*.coffee
There are also two patterns. The compile order should be:
utils.coffee
client.Main.coffee
client.animation.coffee
client.compatibility.coffee
...
In fact, this is the command I use now for my project. I use "Main" instead of "main" just to make sure that it will be compiled before other client files.

Collaborator

michaelficarra commented Jan 23, 2013

@zhanzhenzhen: I think you're still not getting the fact that your shell expands that wildcard before we ever see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment