Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function(options) {
context = {};
}

var includeRegExp = new RegExp(prefix + 'include\\s*\\([^)]*["\'](.*?)["\'](,\\s*({[\\s\\S]*?})){0,1}\\s*\\)+');
var includeRegExp = new RegExp(prefix + 'include\\s*\\([^)"\']*["\']([^"\']*)["\'](,\\s*({[\\s\\S]*?})){0,1}\\s*\\)+');

function fileInclude(file) {
var self = this;
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/index-04.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(function(okanjo) {

okanjo.mvc.registerCss("main", "@@include(jsStringEscape('./test/fixtures/view.html'))", { id: 'okanjo-test-main' });

okanjo.mvc.registerCss("main", '@@include(jsStringEscape("test/fixtures/var.js", { "name": "haoxin", "age": 12345 }))', { id: 'okanjo-test-main' });

})(okanjo);
7 changes: 7 additions & 0 deletions test/fixtures/result.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(function(okanjo) {

okanjo.mvc.registerCss("main", "<h1>view</h1>", { id: 'okanjo-test-main' });

okanjo.mvc.registerCss("main", '<label>haoxin</label><label>12345</label>', { id: 'okanjo-test-main' });

})(okanjo);
1 change: 1 addition & 0 deletions test/fixtures/var.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<label>@@name</label><label>@@age</label>
24 changes: 24 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var fileIncludePlugin = require('..'),

describe('## gulp-file-include', function() {
var result = fs.readFileSync('test/fixtures/result.html', 'utf8');
var resultJS = fs.readFileSync('test/fixtures/result.js', 'utf8');
var resultSamePrefix = fs.readFileSync('test/fixtures/sameprefix-result.html', 'utf8');

describe('# default', function() {
Expand Down Expand Up @@ -350,4 +351,27 @@ describe('## gulp-file-include', function() {
stream.end();
});
});

describe('# aggressive regex', function() {
it('stream - basepath: @root', function(done) {
var file = new gutil.File({
path: 'test/fixtures/index-04.js',
contents: fs.createReadStream('test/fixtures/index-04.js')
});

var stream = fileIncludePlugin({
prefix: '@@',
basepath: '@root'
});
stream.on('data', function(newFile) {
should.exist(newFile);
should.exist(newFile.contents);
String(newFile.contents).should.equal(resultJS);
done();
});

stream.write(file);
stream.end();
});
})
});