Skip to content

Commit

Permalink
Extend plugin options rather than overwrite them.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkemp committed Mar 13, 2018
1 parent bb530b8 commit c302ef5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ function addAssetsToStream(paths, files) {
concat = require('gulp-concat'),
isRelativeUrl = require('is-relative-url'),
vfs = require('vinyl-fs'),
extend = require('extend'),
src,
globs,
name = paths.name,
basePath = paths.basePath,
filepaths = files[name].assets,
type = paths.type,
options = pluginOptions,
options = extend({}, pluginOptions),
gulpConcatOptions = {};

if (!filepaths.length) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"dependencies": {
"event-stream": "^3.3.4",
"extend": "^3.0.1",
"glob": "^7.1.2",
"gulp-concat": "^2.6.1",
"gulp-if": "^2.0.2",
Expand Down
33 changes: 33 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,39 @@ describe('useref()', function() {
stream.end();
});

it('should concat JS assets with newLine option if semicolon', function(done) {
var a = 0,

testFile = getFixture('02.html'),
separator = ';',

stream = useref({newLine: separator}),

buffer1 = new Buffer(fs.readFileSync(path.join('test', 'fixtures', 'scripts', 'this.js'))),
buffer2 = new Buffer(separator),
buffer3 = new Buffer(fs.readFileSync(path.join('test', 'fixtures', 'scripts', 'that.js'))),
bufferFinal = Buffer.concat([buffer1, buffer2, buffer3]),

fileFinal = new Vinyl({ contents: bufferFinal });

stream.on('data', function(newFile){
if (a === 1) {
newFile.path.should.equal(path.normalize('./test/fixtures/scripts/combined.js'));
newFile.contents.toString().should.equal(fileFinal.contents.toString());
}
++a;
});

stream.once('end', function () {
a.should.equal(2);
done();
});

stream.write(testFile);

stream.end();
});

it('should skip concatenation and pass JS assets through with noconcat option', function(done) {
var a = 0;

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ extend-shallow@^3.0.2:
assign-symbols "^1.0.0"
is-extendable "^1.0.1"

extend@^3.0.0, extend@~3.0.1:
extend@^3.0.0, extend@^3.0.1, extend@~3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444"

Expand Down

0 comments on commit c302ef5

Please sign in to comment.