Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Allow user to set output filename #2870

Closed
bdkjones opened this issue Mar 21, 2013 · 13 comments
Closed

CLI: Allow user to set output filename #2870

bdkjones opened this issue Mar 21, 2013 · 13 comments

Comments

@bdkjones
Copy link

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
Copy link
Collaborator

Completely agreed. This is all fixed in redux.

@bdkjones
Copy link
Author

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

@epidemian
Copy link
Contributor

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

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

@vjsingh
Copy link

vjsingh commented Apr 23, 2013

+1

1 similar comment
@xixixao
Copy link
Contributor

xixixao commented Apr 25, 2013

+1

@vendethiel
Copy link
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
Copy link
Contributor

I'd vote for the second one.

@michaelficarra
Copy link
Collaborator

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

@vendethiel
Copy link
Collaborator

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

@xixixao
Copy link
Contributor

xixixao commented Apr 25, 2013

  1. What would happen when compiling multiple files?

  2. Does it work with sourcemaps? Is it just being lazy?

-f --filename        set the output file name

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

@epidemian
Copy link
Contributor

@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
Copy link
Author

Hey all,

Suggestion: just take a look at how Uglify.js 2.0 handles this and copy them. Uglify gives me all sorts of control over the output path, filename and even the path parameters in the sourcemap --- which is exactly what I need to build support for CS Sourcemaps into CodeKit.

I gather that most of you are command line junkies and I sense a bit of disdain for folks that aren't. But there's a lot of people out there who want to use CS through a graphical app like mine and to give them all the features CS has to offer, I need a bit of help on your end.

What is the downside of adding flexibility to the API if it helps expand the reach of CS and does not negatively affect any existing CLI users?

On Apr 25, 2013, at 11:18, Demian Ferreiro notifications@github.com wrote:

@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.


Reply to this email directly or view it on GitHub.

GeoffreyBooth added a commit to GeoffreyBooth/coffeescript that referenced this issue Aug 24, 2017
…s a file and not a path, save as the desired filename
GeoffreyBooth added a commit that referenced this issue Aug 24, 2017
* Fix #2870: If --output ends with a filename, and the input is a file and not a path, save as the desired filename

* If an output path ends in a slash, force saving into an output folder even if that folder name would contain a period (e.g. /scripts.js/); if output filename is only periods, treat it as a path

* Restrict exceptions
@GeoffreyBooth
Copy link
Collaborator

Fixed by #4661.

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

No branches or pull requests

8 participants