Skip to content

Commit

Permalink
Not insert unnecessary blank line.
Browse files Browse the repository at this point in the history
  • Loading branch information
ama-ch committed Apr 23, 2014
1 parent 399dd7b commit 65a37e8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fix.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function getProvideRequireSrc(buf, info) {
return "goog.require('" + namespace + "'); // fixclosure: suppressUnused";
});

if (buf.length > 0 && toRequire.length + suppressed.length > 0) {
if (info.toProvide.length > 0 && toRequire.length + suppressed.length > 0) {
buf.push('');
}

Expand Down
9 changes: 9 additions & 0 deletions test/cli.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ describe 'Command line', ->
expected = fs.readFileSync('test/fixtures/cli/fix-no-provide.js.fixed.txt', encoding: 'utf8')
fixedSrc.should.be.eql expected

it 'fix require-only but not enough requirements file', () ->
fs.copySync('test/fixtures/cli/fix-no-provide2.js', 'test/tmp/fix-no-provide2.js')
cli(cmd.concat(['test/tmp/fix-no-provide2.js', '--fix-in-place']), out, err, exit)
exit.calledOnce.should.be.false

fixedSrc = fs.readFileSync('test/tmp/fix-no-provide2.js', encoding: 'utf8')
expected = fs.readFileSync('test/fixtures/cli/fix-no-provide2.js.fixed.txt', encoding: 'utf8')
fixedSrc.should.be.eql expected

it 'success if a package required with "suppress unused" is not used', () ->
cli(cmd.concat(['test/fixtures/cli/suppress_unused.js', '--showSuccess']), out, err, exit)
exit.calledOnce.should.be.false
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/cli/fix-no-provide2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @fileoverview sample.
*/
goog.require('goog.foo');

goog.foo.bar();
goog.bar.baz();
8 changes: 8 additions & 0 deletions test/fixtures/cli/fix-no-provide2.js.fixed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @fileoverview sample.
*/
goog.require('goog.bar');
goog.require('goog.foo');

goog.foo.bar();
goog.bar.baz();

0 comments on commit 65a37e8

Please sign in to comment.