Commit Graph

4 Commits

Author SHA1 Message Date
Geoffrey Booth 8a25195442
AST flag/API option; generic AST output for all nodes (#5044)
* Add `nodes` option to Node API, that returns POJO representation of AST; starting point for toPlainObject method on node classes to return the serializable plain JavaScript object representation of each node

* Make --nodes also return JSON (pretty-printed, though not colorized)

* Alphabetize CLI flags

* Use new `ast` flag to request AST, restoring prior `nodes` flag; rename toPlainObject to toJSON
2018-06-11 19:50:40 -07:00
Geoffrey Booth f51c1a150b Option to transpile with Babel (#4697)
* Upgrade Babeli (now babel-minify) which fixes the bug that was forcing us to run Babel twice for transpilation

* Add --transpile option (WIP)

* Node API always compiles a string, so it doesn’t need the option to pass a path to an options file, it can always just pass an object to `transpile`; get `transpile` working with `eval`

* Not allowing argument to `--transpile` so don’t need to cover so many cases

* Don’t need to worry about `sourceMaps` option to pass to Babel, `inputSourceMap` overrides it

* Rewrite Webpack test to use Node API

* Make the compiler safe again for browsers and Webpack/Browserify

* Node version of CoffeeScript.compile passes reference to Babel if transpile is requested

* Test Node API for transpile option

* Test for merged source maps

* Test for Node API error message

* Only stop searching for Babel options if a package.json has a truthy "babel" key

* Update docs
2017-09-15 06:58:18 -07:00
Geoffrey Booth 3dd458267b [CS2] Fix #2870: Allow specifying output filename (#4661)
* 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
2017-08-24 00:03:57 -07:00
Danny McClanahan 4e57ca6833 [CS2] Add #! support for executable scripts on Linux. (#3946)
* Add #! support for executable scripts on Linux.

Pass arguments to executable script unchanged if using "#!/usr/bin/env
coffee". (Previously, "./test.coffee -abck" would be turned into "-a -b -c -k",
for example.)

Fixes #1752.

* refactor option parsing

clean up parsing code and in the process fix oustanding bug where coffeescript
modified arguments meant for an executable script

* address comments

* intermediate save

* add note saying where OptionParser is used in coffee command

* add some more work

* fix flatten functions

* refactor tests

* make argument processing less confusing

* add basic test

* remove unused file

* compilation now hangs

* remove unnecessary changes

* add tests!!!

* add/fix some tests

* clarify a test

* fix helpers

* fix opt parsing

* fix infinite loop

* make rule building easier to read

* add tests for flag overlap

* revamp argument parsing again and add more thorough testing

* add tests, comment, clean unused method

* address review comments

* add test for direct invocation of shebang scripts

* move shebang parsing test to separate file and check for browser

* remove TODO

* example backwards compatible warnings

* add correct tests for warning 1

* add tests for warnings

* commit output js libs and update docs

* respond to review comments

also add tests for help text

* respond to review comments

* fix example output

* Rewrite argument parsing documentation to be more concise; add it to sidebar and body; add new output

* Don’t mention deprecated syntax; clean up variable names
2017-07-19 16:25:06 -07:00