satyr / coco

Unfancy CoffeeScript
http://satyr.github.com/coco/
MIT License
497 stars 48 forks source link

`coco -c` loses `.js` suffix when filename contains more than one `.` #234

Open ksdlck opened 11 years ago

ksdlck commented 11 years ago

coco -c seems to be dropping the expected .js suffix when invoked on a file that contains more than one . in its name. Consider the following:

$ ls
test.co                         test.filename.with.more.dots.co
test.filename.co
$ coco -c test.co
$ coco -c test.filename.co
$ coco -c test.filename.with.more.dots.co
$ ls
test.co                         test.filename.with.more.dots
test.filename                   test.filename.with.more.dots.co
test.filename.co                test.js

The contents of all compiled files are correct, but two of three lack the expected .js suffix.

vendethiel commented 11 years ago

155

ksdlck commented 11 years ago

I must admit, I'm not particularly convinced by this argument. Coco has always adopted a strongly "It's just Javscript" mentality, and this somehow feels contradictory to that, if only peripherally. Is it possible that the real problem is that coco has never had an option for outputting to a file, as opposed to -o which outputs to a predetermined filename in the specified directory? Naturally, the same can be accomplished by -p and redirection to your filename of choice, e.g. (as a counter to #155):

$ coco -cp test.jsm.co > test.jsm

It strikes me that the default behavior should be consistent regardless of the number of suffixes the filename has. I'm ok with applying the solution above in reverse to deal with the current behavior, but why is this the default? Are there lots of folks out there finding this behavior helpful?