Skip to content

Commit

Permalink
Fixed whitespace issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jmerle committed Jun 25, 2017
1 parent 8079f7e commit 5a18e43
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ gulp.task('default', function() {
## Usage
merge(fileName, options)

- `fileName`: The name of the generated file
- `fileName`: The name of the generated file.
- `options`
- `publicMain`: Make all classes containing a `public static void main` method public.
- `removePackage`: Remove the package line on-top of the file.
- `publicMain` (default: `false`): Make all classes containing a `public static void main` method public.
- `removePackage` (default: `false`): Remove the package line on-top of the file.

## A few things
- Only works for a single package (i.e. you can't merge two packages into one bundled file).
Expand Down
10 changes: 4 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = function(fileName, options) {
unshift = true;
}

code = code.join('\n').trim() + '\n';
code = code.join('\n').trim();

if (unshift) {
processedCode.unshift(code);
Expand Down Expand Up @@ -92,19 +92,17 @@ module.exports = function(fileName, options) {
let finalFile = '';

if (package !== null && !options.removePackage) {
finalFile += package;
if (imports.length > 0 || processedCode.length > 0) {
finalFile += '\n\n';
}
finalFile += package + '\n';
}

if (imports.length > 0) {
if (package !== null && !options.removePackage) finalFile += '\n';
finalFile += imports.join('\n') + '\n';
}

if (processedCode.length > 0) {
if (imports.length > 0 || (package !== null && !options.removePackage)) finalFile += '\n';
finalFile += processedCode.join('\n');
finalFile += processedCode.join('\n\n') + '\n';
}

cb(null, new File({
Expand Down
4 changes: 3 additions & 1 deletion test/input/withpackage.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.jaspervanmerle.somecoolpackagename;

import java.util.Date;

class Hi {
public String hello = "Hello";
public String world = "World";
}
}
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('gulp-java-merger', function() {
}))
.pipe(assert.length(1))
.pipe(assert.first(function(d) {
d.contents.toString().split('\n').length.should.eql(5);
d.contents.toString().split('\n').length.should.eql(7);
}))
.pipe(assert.end(done));
});
Expand Down

0 comments on commit 5a18e43

Please sign in to comment.