CLI: Allow user to set output filename #2870

Open
bdkjones opened this Issue Mar 21, 2013 · 12 comments

7 participants

@bdkjones

Suppose we have a file named "master.coffee".

Right now, the CLI for CoffeeScript allows us to specify a specific folder where we want the compiled Javascript file created:

--output /folder/subfolder/outputHere

This will generate the following file:

/folder/subfolder/outputHere/master.js

But in many cases, we might want the name of the output file to be different than the name of the source file. I would like the --output flag to support this possibility. If the supplied path ends with a file rather than a folder, the Coffee compiler should use that name for the output file. Example:

--output /folder/somefolder/awesome.js

CoffeeScript is the only "cutting edge" tool on the market that doesn't have the capability to specify complete output file paths. I know it may seem like a small thing, but when building CoffeeScript into other apps or tools, it really is a frustrating limitation. It's even more of an issue now that CS supports source maps, so we can't just change the file names on the fly; they're hard-coded into the maps.

@michaelficarra
Collaborator

Completely agreed. This is all fixed in redux.

@bdkjones

Any idea when it's going to make its way into the shipping version?

@epidemian

You can always use the -s option to make the coffee command more UNIX-friendly:

coffee -cs <src/bla.coffee >lib/master.js
@vjsingh

+1

@xixixao

+1

@vendethiel
Collaborator

Do we

1) add a new option to specify file name
2) change current output to "ouput to file" if there's a dot in it ?
3) Promote -s

@epidemian

I'd vote for the second one.

@michaelficarra
Collaborator

I'd go with 0. do nothing; recommend use of -s option

@vendethiel
Collaborator

-s is many times rather inconvenient (when running cli commands from other tools, for example), but I added it as 3).

@xixixao

2) What would happen when compiling multiple files?
3) Does it work with sourcemaps? Is it just being lazy?

1)

-f --filename        set the output file name

warn when passing multiple file names OR join by default
4) -j accepts a file name

@epidemian

@michaelficarra, well, yeah, i'd rather go with the same option of using stdin/stdout. I very much dislike all the bloat of having redundant options on UNIX-like commands. But given that the Coffee compiler already takes its input and output as file name arguments, i think that the second option mentioned by @Nami-Doc would be the best compromise.

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