Skip to content

Commit

Permalink
fix --no-warn flag
Browse files Browse the repository at this point in the history
  • Loading branch information
pepkin88 authored and rhendric committed Aug 4, 2018
1 parent 94f429b commit c830b55
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lib/ast.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions lib/options.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions scripts/test
Expand Up @@ -183,7 +183,7 @@

try {
console.log(filename);
LiveScript.run(code, { filename: filename, map: 'embedded', noWarn: true });
LiveScript.run(code, { filename: filename, map: 'embedded', warn: false });
} catch (e) {
++failedTests;

Expand All @@ -209,7 +209,7 @@
col = ref[2];
code = LiveScript.compile(code, {
bare: true,
noWarn: true
warn: false
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/ast.ls
Expand Up @@ -1430,7 +1430,7 @@ class exports.Binary extends Node
return @compileRegexEquals o, that
if @op is \=== and (@first instanceof Literal and @second instanceof Literal)
and @first.is-what! isnt @second.is-what!
@warn "strict comparison of two different types will always be false: #{@first.value} == #{@second.value}" unless o.no-warn
@warn "strict comparison of two different types will always be false: #{@first.value} == #{@second.value}" if o.warn
return @compileChain o if COMPARER.test @op and COMPARER.test @second.op
@first <<< {@front}
code = [(@first .compile o, level = LEVEL_OP + PREC[@op]), " ", (@mapOp @op), " ", (@second.compile o, level)]
Expand Down Expand Up @@ -1918,7 +1918,7 @@ class exports.In extends Node implements Negatable
if array not instanceof Arr
return sn(this, (if @negated then \! else ''), (util \in), "(", (@item.compile o, LEVEL_LIST), ", ", (array.compile o, LEVEL_LIST), ")")
if items.length == 0
@warn "value can never be `in` an empty array" unless o.no-warn
@warn "value can never be `in` an empty array" if o.warn
value = "#{!!@negated}"
return do
if @item.is-complex!
Expand Down
2 changes: 1 addition & 1 deletion src/command.ls
Expand Up @@ -113,7 +113,7 @@ switch
o.const
o.map
o.header
o.no-warn
o.warn
}
t = {input, options}
try
Expand Down
1 change: 1 addition & 0 deletions src/index.ls
Expand Up @@ -33,6 +33,7 @@ exports <<<

# Compiles a string of LiveScript code to JavaScript.
compile: (code, options = {}) ->
options.warn ?= true
options.header ?= true
options.header = "// Generated by LiveScript #{exports.VERSION}\n" if options.header is true
try
Expand Down
3 changes: 2 additions & 1 deletion src/options.ls
Expand Up @@ -97,9 +97,10 @@ module.exports = optionator do
alias: 'm'
type: 'String'
description: "generate source maps - either: 'none', 'linked', 'linked-src', 'embedded', or 'debug'"
* option: 'no-warn'
* option: 'warn'
type: 'Boolean'
description: 'suppress compiler warnings'
default: 'true'
mutually-exclusive:
* [ <[ compile output ]> \ast \tokens \lex ]
...
8 changes: 4 additions & 4 deletions test/operator.ls
Expand Up @@ -92,10 +92,10 @@ ok not ("2" in [1 2 3])
# Optimize `in` for one- and zero-element array literals
eq "x() === 0;" LiveScript.compile 'x! in [0]' {+bare,-header}
eq "x() !== 0;" LiveScript.compile 'x! not in [0]' {+bare,-header}
eq "(x(), false);" LiveScript.compile 'x! in [ ]' {+bare,-header,+no-warn}
eq "(x(), true);" LiveScript.compile 'x! not in [ ]' {+bare,-header,+no-warn}
eq "false;" LiveScript.compile 'x in [ ]' {+bare,-header,+no-warn}
eq "true;" LiveScript.compile 'x not in [ ]' {+bare,-header,+no-warn}
eq "(x(), false);" LiveScript.compile 'x! in [ ]' {+bare,-header,-warn}
eq "(x(), true);" LiveScript.compile 'x! not in [ ]' {+bare,-header,-warn}
eq "false;" LiveScript.compile 'x in [ ]' {+bare,-header,-warn}
eq "true;" LiveScript.compile 'x not in [ ]' {+bare,-header,-warn}

# Non-spaced values still work.
x = 10
Expand Down

0 comments on commit c830b55

Please sign in to comment.