• Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

plugin for gulp to ignore files in the stream based on file characteristics

gulp-ignore status

Include or exclude gulp files from the stream based on a condition

Usage

1: Exclude things from the stream

Exclude things from entering the stream

var uglify = require('gulp-uglify');

gulp.task('task', function() {
  gulp.src(['./**/*.js', '!./node_modules/**'])
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

Grab all JavaScript files that aren't in the node_modules folder, uglify them, and write them. This is fastest because nothing in node_modules ever leaves gulp.src()

2: Remove things from the stream

Remove from here on

var gulpIgnore = require('gulp-ignore');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');

var condition = './gulpfile.js';

gulp.task('task', function() {
  gulp.src('./**/*.js')
    .pipe(jshint())
    .pipe(gulpIgnore.exclude(condition))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

Run JSHint on everything, remove gulpfile from the stream, then uglify and write everything else.

3: Filter only matching things

Include from here on

var gulpIgnore = require('gulp-ignore');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');

var condition = './public/**.js';

gulp.task('task', function() {
  gulp.src('./**/*.js')
    .pipe(jshint())
    .pipe(gulpIgnore.include(condition))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

Run JSHint on everything, filter to include only files from in the public folder, then uglify and write them.

4: Conditionally filter content, include everything down-stream

Condition

var gulpif = require('gulp-if'); // This is gulp-if, not gulp-ignore
var uglify = require('gulp-uglify');

var condition = function(file) {
  // Only files whose contents match a pattern
  return /a pattern/g.test(String(file.contents));
};

gulp.task('task', function() {
  gulp.src('./src/*.js')
    .pipe(gulpif(condition, uglify()))
    .pipe(gulp.dest('./dist/'));
});

Only uglify the content if the condition is true, but send all the files to the dist folder.

API

exclude(condition [, minimatchOptions])

Exclude files whose file.path matches, include everything else

include(condition [, minimatchOptions])

Include files whose file.path matches, exclude everything else

condition

Type: boolean or stat object or function that takes in a vinyl file and returns a boolean or RegularExpression that works on the file.path

The condition parameter is any of the conditions supported by gulp-match. The file.path is passed into gulp-match.

If a function is given, then the function is passed a vinyl file. The function should return a boolean.

minimatchOptions

Optional, if it's a glob condition, these options are passed to https://github.com/isaacs/minimatch.

LICENSE

(MIT License)

Copyright (c) 2014 Richardson & Sons, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

orchestrator

A module for sequencing and executing tasks and dependencies in maximum concurrency
JavaScript
1,226
star
2

gulp-exec

exec plugin for gulp
JavaScript
160
star
3

gulp-rimraf

rimraf plugin for gulp
JavaScript
149
star
4

kubernetes-hands-on-workshop

Let's learn Docker and Kubernetes!
JavaScript
103
star
5

pretty-hrtime

process.hrtime() to words
JavaScript
66
star
6

levelup-devops-github-actions-kubernetes

Live-coding a DevOps pipeline using GitHub Actions and deploying to Kubernetes
HTML
56
star
7

git-explorer

view all DAG nodes in the .git/objects folder
TypeScript
53
star
8

docker-hands-on-workshop

C#
47
star
9

ternary-stream

A ternary stream: conditionally control the flow of stream data
JavaScript
37
star
10

sequencify

A module for sequencing tasks and dependencies
JavaScript
33
star
11

minimal-apis-aspnet

A presentation about new C# features and Minimal APIs in ASP.NET. See https://robrich.org/ for more.
HTML
31
star
12

docker-vue-and-aspnetcore

Docker Isn't All Hype; Create Robust Deployments for Vue.js and ASP.NET Core
C#
28
star
13

database-devops-with-containers

Database DevOps with Containers, the companion to https://robrich.org/slides/database-devops-with-containers/#/
HTML
25
star
14

gulp-match

Does a vinyl file match a condition?
JavaScript
23
star
15

product-catalog

Reference architecture microservice API in TypeScript, Node.js, Vue.js and MemSQL
TypeScript
20
star
16

https-aspnet-core-docker-deep-dive

Demos for https://robrich.org/slides/https-aspnet-core-docker-deep-dive/#/
C#
16
star
17

gaining-confidence-cypress-tests

The code for Gaining Confidence with Cypress Tests at https://robrich.org/slides/gaining-confidence-cypress-tests/#/
TypeScript
16
star
18

create-robust-deployments-for-spa-and-api

Companion code to "Create Robust Deployments for your SPA and API", https://robrich.org/slides/create-robust-deployments-for-spa-and-api/#/
Vue
14
star
19

database-devops-pipeline

A Database DevOps Pipeline, the companion code to https://robrich.org/slides/database-devops-pipeline/
C#
14
star
20

javascript-testing-presentation

JavaScript Testing in Node, the Browser, and CI
JavaScript
13
star
21

at-the-helm-of-kubernetes

The code for the talk at https://robrich.org/slides/at-the-helm-of-kubernetes/
HTML
12
star
22

docker-in-windows-containers

C#
8
star
23

net-testing-xunit-moq

.NET Testing Best Practices
C#
7
star
24

vue-and-typescript-like-peanut-butter-and-jelly

The companion code to the talk https://robrich.org/slides/vue-and-typescript-like-peanut-butter-and-jelly/#/
Vue
7
star
25

es6-the-language-and-the-tools-workshop

Introduction to ES6: the language and the tools, a workshop
CSS
6
star
26

web-test-all-the-things

The code for https://robrich.org/slides/web-test-all-the-things/
TypeScript
6
star
27

kubernetes-test-drive

HTML
5
star
28

ConferenceScheduler

C#
5
star
29

DevOps-Pipeline-for-.NET-Apps-and-Databases-Workshop

4
star
30

iodist

An io.js version manager for the windows folks out there.
JavaScript
3
star
31

Asynchrony_in_JavaScript

JavaScript
3
star
32

litedb-and-docker

This is a demo of using LiteDB with Docker.
C#
3
star
33

async-python

The code samples from the talk at https://robrich.org/slides/async-python/
Python
3
star
34

your-technology-your-way

C#
3
star
35

aspnet-dos-and-donts-for-highly-maintainable-code

JavaScript
2
star
36

TestingInNetCore

C#
2
star
37

AzureScheduler

A web app / web job for starting and stopping Azure resources via the Azure SDK
C#
2
star
38

gulp_node_example

An example gulpfile for Node projects
JavaScript
2
star
39

execify

A module for shimmimg between execution modes: streams, promises, and callbacks
JavaScript
2
star
40

great-net-microservices

This is the companion code to [Building Great .NET Microservices](https://robrich.org/slides/great-net-microservices/).
C#
2
star
41

LoggingSample

A sample of logging client- and server-side errors to the database and to email in .NET
C#
2
star
42

BetaSigmaPhi

C#
2
star
43

jupyter_getting_started

Jupyter demos showing various use-cases
Jupyter Notebook
2
star
44

FluentValidationPlayground

JavaScript
1
star
45

mocking-typescript

The code samples for the talk [Mocking in TypeScript](https://robrich.org/slides/mocking-typescript/)
TypeScript
1
star
46

githubactionsplayground

HTML
1
star
47

WelcomeToNode

CSS
1
star
48

levelup-devops-github-actions-azure-functions

Live-coding a DevOps pipeline using GitHub Actions deploying to Azure Functions consumption
C#
1
star
49

MapD

C#
1
star
50

azure-devops-aks

Level-up Your DevOps with Azure and Kubernetes
HTML
1
star
51

robrich

About Rob Richardson | rob rich
1
star
52

handlebars-sample

An example of using Handlebars in both a traditional form post model and in a single page application (SPA)
JavaScript
1
star
53

gulp_dotnet_example

An example gulpfile for Microsoft .NET projects
JavaScript
1
star
54

cactus

JavaScript
1
star
55

git-scenarios

1
star
56

VersionSample

Git hash into assembly on build, read it back onto the site
JavaScript
1
star
57

santas-helper

Team hack for HolidayJS 2015
JavaScript
1
star
58

XamarinExample

Creating Cross Platform Apps with Xamarin Studio
C#
1
star
59

browser-control-test-app

An app that compares Windows Forms browser controls on .NET Framework
C#
1
star