gulp-resolve-dependencies
Advanced tools
Comparing version 4.0.0 to 4.1.0
28
index.js
@@ -11,3 +11,4 @@ 'use strict'; | ||
DAG = require('dag'), | ||
cloneRegexp = require('clone-regexp'); | ||
cloneRegexp = require('clone-regexp'), | ||
minimatch = require('minimatch'); | ||
@@ -23,3 +24,5 @@ var PLUGIN_NAME = 'gulp-resolve-dependencies'; | ||
return path.join(path.dirname(path.resolve(targetFile.path)), match); | ||
} | ||
}, | ||
exclude: [], | ||
include: [] | ||
}, | ||
@@ -52,3 +55,4 @@ stream, | ||
filePath = config.resolvePath(match[1], targetFile); | ||
// Ignore falsy returns | ||
if (!filePath) { | ||
@@ -62,2 +66,20 @@ if (config.log) { | ||
// Check include | ||
if (config.include && config.include.length !== 0 && !config.include.some(_ => minimatch(filePath, _))) { | ||
if (config.log) { | ||
Log('[' + AnsiColors.green(PLUGIN_NAME) + '] File not included:', filePath); | ||
} | ||
continue; | ||
} | ||
// Check exclude | ||
if (config.exclude && config.exclude.some(_ => minimatch(filePath, _))) { | ||
if (config.log) { | ||
Log('[' + AnsiColors.green(PLUGIN_NAME) + '] File excluded:', filePath); | ||
} | ||
continue; | ||
} | ||
// Check for circular dependencies | ||
@@ -64,0 +86,0 @@ try { |
{ | ||
"name": "gulp-resolve-dependencies", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Resolve dependency directives in assets (e.g. \"@requires\" or \"//= require\" in JavaScript)", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -102,3 +102,13 @@ # gulp-resolve-dependencies | ||
#### options.include | ||
Type: `Array` | ||
Only dependencies matching this array of absolute paths will be included (defaults to ```[]```). | ||
#### options.exclude | ||
Type: `Array` | ||
Dependencies matching this array of absolute paths will be excluded (defaults to ```[]```). | ||
## Contributors | ||
@@ -110,1 +120,2 @@ | ||
* @adrianosanti: [Outdated dependencies](https://github.com/backflip/gulp-resolve-dependencies/pull/18) | ||
* @Nauja: [Include/exclude options](https://github.com/backflip/gulp-resolve-dependencies/pull/23) |
@@ -113,2 +113,28 @@ var gulp = require('gulp'), | ||
}); | ||
it('should exclude depencencies from fixtures/libs', function(done) { | ||
gulp.src(__dirname + '/fixtures/main.js') | ||
.pipe(resolveDependencies({ | ||
exclude: [path.resolve(__dirname, "fixtures/libs/**/*")] | ||
})) | ||
.pipe(concat('mainexclude.js')) | ||
.pipe(gulp.dest(__dirname + '/results/')) | ||
.pipe(es.wait(function() { | ||
assertFilesEqual('mainexclude.js'); | ||
done(); | ||
})); | ||
}); | ||
it('should only include depencencies from fixtures/test', function(done) { | ||
gulp.src(__dirname + '/fixtures/main.js') | ||
.pipe(resolveDependencies({ | ||
include: [path.resolve(__dirname, "fixtures/test/**/*")] | ||
})) | ||
.pipe(concat('maininclude.js')) | ||
.pipe(gulp.dest(__dirname + '/results/')) | ||
.pipe(es.wait(function() { | ||
assertFilesEqual('maininclude.js'); | ||
done(); | ||
})); | ||
}); | ||
}); |
16048
22
359
120