Skip to content

Commit

Permalink
v0.13.7
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxin committed Jul 25, 2015
1 parent f011979 commit 9b5c933
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/replace-function.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var balanced = require('balanced-match');

module.exports = function (content, opts) {
module.exports = function(content, opts) {
var result = '';
var reStart = new RegExp(opts.prefix + '[ ]*' + opts.name + '\\(');
var reEnd = new RegExp('^[ ]*' + opts.suffix);
Expand All @@ -11,26 +11,26 @@ module.exports = function (content, opts) {
var before;
var replacement;

while(matchStart = reStart.exec(content)) {
while (matchStart = reStart.exec(content)) {
safeStart = matchStart.index + matchStart[0].length - 1;

matchArg = balanced('(', ')', content.slice(safeStart));

if(matchArg && matchArg.start === 0) {
if(opts.suffix) {
if (matchArg && matchArg.start === 0) {
if (opts.suffix) {
matchEnd = reEnd.exec(matchArg.post);
}

matchEnd = matchEnd ? matchEnd.index + matchEnd[0].length : 0;

if(!opts.suffix || matchEnd) {
if (!opts.suffix || matchEnd) {
before = content.slice(0, matchStart.index);
replacement = opts.handler({
before: before,
args: matchArg.body,
});

if(replacement !== undefined) {
if (replacement !== undefined) {
result += before + replacement.toString();
content = content.slice(safeStart + matchArg.end + 1 + matchEnd);
continue;
Expand Down
2 changes: 1 addition & 1 deletion lib/replace-operator.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function parse(content, opts) {
body: matchBody.body
});

if(replacement !== undefined) {
if (replacement !== undefined) {
result += before + parse(replacement.toString(), opts);
content = content.slice(startEnd + matchBody.end + matchEnd);
continue;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-file-include",
"version": "0.13.6",
"version": "0.13.7",
"description": "a gulp plugin for file include",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit 9b5c933

Please sign in to comment.