Giter VIP home page Giter VIP logo

gulp-ignore's Introduction

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.

gulp-ignore's People

Contributors

akaleeroy avatar ichivack avatar robrich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gulp-ignore's Issues

Support regex

I'm adding support for this in core just thought it should stay consistent

Filtering by Filesize

I'm trying to filter some files by it's filesize but i'm getting some errors:

I'm trying to check if the file has some content in it (because sometimes it doesnt)

var isThereContent = function(file) {
    var fileStat = fs.fstatSync(file);

       if (fileStat.size > 1000) {
            return true;
       } else {
              return false;
       }
}
gulp.src(config.directory.src)
        .pipe(gulpIgnore.include(isThereContent))
        .pipe(rename(renameFiles))
        .pipe(gulp.dest(config.directory.dest));

I get the following error:

  return binding.fstat(fd);
                 ^
TypeError: Bad argument
    at Object.fs.fstatSync (fs.js:674:18)

Would you be able to help?

Better file matching?

I would expect any one of the globs /home/dev/devenv/dappsys/src/sol/token/old_asset/*, /home/dev/devenv/dappsys/src/sol/token/old_asset/*.*, and /home/dev/devenv/dappsys/src/sol/token/old_asset/*.sol to match the path /home/dev/devenv/dappsys/src/sol/token/old_asset/asset0.sol, but it appears that none of them presently do.

Edit: I'm assuming this is a bug, not a feature. Please correct me if I'm wrong here.

[question] Array of globs

Does filepath / condition line up with gulp.src? IE can I pass an array of conditions? That way I can have a single ignore statement.

Gulp ignore, not ignoring.

In my Gulpfile I have the following Task:

// HTML
gulp.task('html', function() {
  return  gulp.src(path.join(config.src, '/**/*.html'))
    .pipe(ignore.exclude(config.include))
    .pipe(fileinclude())
    .pipe(connect.reload())
    .pipe(gulp.dest(config.dist))
});

I am using gulp-ignore to exclude the includes directory however it is not working and includes all ways ends up in the dist folder.

I assume I have set the variable right:

var config = {
   include: 'src/includes' // Includes Directory
};

so this is the line I am having trouble with:

.pipe(ignore.exclude(config.include))

Anyone come across something similar?

Full Gulpfile.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.