gulp-include
Advanced tools
Comparing version 2.2.0 to 2.2.1
16
index.js
@@ -143,7 +143,7 @@ var fs = require('fs'), | ||
var includePath = ""; | ||
if (includePaths != false) { | ||
// If includepaths are set, search in those folders | ||
for (var y = 0; y < includePaths.length; y++) { | ||
var includePath = includePaths[y] + "/" + split[1]; | ||
includePath = includePaths[y] + "/" + split[1]; | ||
@@ -155,6 +155,10 @@ var globResults = glob.sync(includePath, {mark: true}); | ||
// Otherwise search relatively | ||
var includePath = relativeBasePath + "/" + split[1]; | ||
fileMatches = glob.sync(includePath, {mark: true}); | ||
includePath = relativeBasePath + "/" + split[1]; | ||
var globResults = glob.sync(includePath, {mark: true}); | ||
if (globResults.length < 1) fileNotFoundError(includePath); | ||
fileMatches = globResults; | ||
} | ||
if (fileMatches.length < 1) fileNotFoundError(includePath); | ||
var replaceContent = ''; | ||
@@ -281,2 +285,6 @@ for (var y = 0; y < fileMatches.length; y++) { | ||
function fileNotFoundError(includePath) { | ||
throw new gutil.PluginError('gulp-include', 'No files found matching ' + includePath); | ||
} | ||
function inExtensions(filePath) { | ||
@@ -283,0 +291,0 @@ if (!extensions) return true; |
{ | ||
"name": "gulp-include", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Makes inclusion of files a breeze. Enables functionality similar to that of snockets / sprockets or other file insertion compilation tools.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/wiledal/gulp-include", |
@@ -40,4 +40,5 @@ #gulp-include [![NPM version][npm-image]][npm-url] ![Travis build][travis-image] | ||
- `extensions` (optional) | ||
* Takes a `String` or an `Array` of extensions, eg: `"js"` or `["js", "coffee"]` | ||
* If set, all directives that does not match the extension(s) will be ignored | ||
* Takes a `String` or an `Array` of extensions, eg: `"js"` or `["js", "coffee"]` | ||
* If set, all directives that does not match the extension(s) will be ignored | ||
- `includePaths` (optional) | ||
@@ -47,2 +48,15 @@ * Takes a `String` or an `Array` of paths, | ||
* If set, `gulp-include` will use these folders as base path when searching for files. | ||
#### Example options usage: | ||
```js | ||
gulp.src("src/js/main.js") | ||
.pipe(include({ | ||
extensions: "js", | ||
includePaths: [ | ||
__dirname + "/bower_components", | ||
__dirname + "/src/js" | ||
] | ||
})) | ||
.pipe(gulp.dest("dist/js")); | ||
``` | ||
@@ -80,2 +94,5 @@ ## Include directives | ||
## Release log | ||
#### 2.2.1 | ||
* Now throws an error if glob match is unmet | ||
#### 2.2.0 | ||
@@ -82,0 +99,0 @@ * Added `includePaths` option |
27555
509
183