gulp-file-include
Advanced tools
Comparing version 0.6.0 to 0.7.0
28
index.js
@@ -96,17 +96,7 @@ 'use strict'; | ||
function include(file, text) { | ||
var filebase = basepath === "@file" ? path.dirname(file.path) : basepath === "@root" ? process.cwd() : basepath; | ||
var matches = includeRegExp.exec(text); | ||
switch (basepath) { | ||
case '@file': | ||
basepath = path.dirname(file.path); | ||
break; | ||
case '@root': | ||
basepath = process.cwd(); | ||
break; | ||
default: | ||
break; | ||
} | ||
filebase = path.resolve(process.cwd(), filebase); | ||
basepath = path.resolve(process.cwd(), basepath); | ||
// for checking if we are not including the current file again | ||
@@ -117,3 +107,3 @@ var currentFilename = path.resolve(file.base, file.path); | ||
var match = matches[0]; | ||
var includePath = path.resolve(basepath, matches[1]); | ||
var includePath = path.resolve(filebase, matches[1]); | ||
@@ -137,2 +127,14 @@ if (currentFilename.toLowerCase() === includePath.toLowerCase()) { | ||
var recMatches = includeRegExp.exec(includeContent); | ||
if (recMatches && basepath == "@file") { | ||
var recFile = new gutil.File({ | ||
cwd: process.cwd(), | ||
base: file.base, | ||
path: includePath, | ||
contents: new Buffer(includeContent) | ||
}); | ||
recFile = include(recFile, includeContent); | ||
includeContent = String(recFile.contents); | ||
} | ||
text = text.replace(match, includeContent); | ||
@@ -139,0 +141,0 @@ |
{ | ||
"name": "gulp-file-include", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "a gulp plugin for file include", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -41,4 +41,2 @@ [![NPM version][npm-img]][npm-url] | ||
**important**: `@file` is relative to the `file` pass to gulp, not the file `include expression` in, see [example](example) | ||
```js | ||
@@ -45,0 +43,0 @@ fileinclude({ |
9561
142
168