babel-core: add options for different parser/generator (#3561)

* babel-core: add options for different parser/generator

* test for experiemental plugins, other babylon options

* fix passing options into parser

* Fix when no code is provided

* fixup tests

* fix tests again

* use filename and fallback to cwd
This commit is contained in:
Henry Zhu
2016-09-27 09:09:31 -04:00
committed by GitHub
parent 90f3f9049f
commit b2eb5eca6f
4 changed files with 136 additions and 3 deletions

View File

@@ -93,6 +93,11 @@ function normalizeOptions(code, opts, tokens): Format {
* Determine if input code uses more single or double quotes.
*/
function findCommonStringDelimiter(code, tokens) {
const DEFAULT_STRING_DELIMITER = "double";
if (!code) {
return DEFAULT_STRING_DELIMITER;
}
let occurences = {
single: 0,
double: 0
@@ -117,7 +122,7 @@ function findCommonStringDelimiter(code, tokens) {
if (occurences.single > occurences.double) {
return "single";
} else {
return "double";
return DEFAULT_STRING_DELIMITER;
}
}