-
Notifications
You must be signed in to change notification settings - Fork 51
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
Convert to JS #22
Open
gitgrimbo
wants to merge
8
commits into
sgentle:master
Choose a base branch
from
gitgrimbo:convert-to-js
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Convert to JS #22
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit contains two variations of conversion. The most appropriate one should be used in a refactored PR. decaffeinate: https://github.com/decaffeinate/decaffeinate - pros - retains comments - uses es6 - let and const - template strings - lists recommendations for further conversion improvements - uses one declaration per line (personal preference) - cons - compact object literals on one line (personal preference) - e.g. current = {version, support, usage: 0}; - ifs on one line (personal preference) - e.g. if (nums == null) { nums = {}; } js2coffee: https://github.com/js2coffee/js2coffee - pros - TODO - cons - TODO
js-beautify -r --indent-size 2 INPUT-FILE
bin.js now requires caniuse-cli.js, and not the coffee-script files. The new caniuse-cli.js file is a CLI-only file that requires caniuser.decaffeinate.js caniuse.decaffeinate.js now provides two main functions: - toStreams() which will output to either default stdout and stderr, or two streams of your choice. - asString() which will return the output as a string. This separation will make it simple for other JS code to use the module to extract the output and use it in other situations, e.g. converting to HTML.
gitgrimbo
force-pushed
the
convert-to-js
branch
from
September 19, 2018 14:06
3aa6ad4
to
83c91f1
Compare
So we can use the args parser (and more importantly, the default argument values it provides) in other code, e.g.: ```js const caniuse = require("caniuse-cmd"); const args = process.argv.slice(2); console.log(caniuse.asString(args)); ```
gitgrimbo
force-pushed
the
convert-to-js
branch
from
September 19, 2018 14:46
2b5719e
to
7ca27df
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
References #18.
I would say this PR is indicative at the moment and will require some rework, which I'm happy to do.
E.g. I have included two variations of automatic conversion from coffee-script to JS, using:
I have also left most of the indentation alone in order to simplify diffs. The finished code would require proper formatting.
The PR builds on the decaffeinate conversion as I preferred its output.