New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gulp-cond

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-cond

Ternary operator for Gulp.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

gulp-cond

Ternary operator for Gulp.

GitHub license

Usage

First, install gulp-cond as a development dependency:

npm install --save-dev gulp-cond

Then, use it to conditionally pipe plugins in your gulpfile.js:

import cond from 'gulp-cond';
var prod = gulp.env.prod;

// Images
gulp.task('build_images', function() {
  gulp.src('assets/images/**/*.svg')
    .pipe(cond(prod,
      gSvgmin(options), // minify SVG images under production
      gWatch().pipe(gLivereload(server))) // use live reload in dev mode
    )
    .pipe(gulp.dest('www/images'))
});

Alternatively, you can provide plugin functions instead of streams to instantiate streams only when needed :

import cond from 'gulp-cond';
var prod = gulp.env.prod;

// Images
gulp.task('build_images', function() {
  gulp.src('assets/images/**/*.svg')
    .pipe(cond(prod,
      gSvgmin.bind(null, options), // minify SVG images under production
      function () { // use live reload in dev mode
        return gWatch().pipe(gLivereload(server));
      })
    )
    .pipe(gulp.dest('www/images'))
});

API

cond(condition, expr1, expr2)

condition

Type: Boolean or Function

Required. A value or a function providing a value. If the value is truthy, expr1 will be used, else, expr2 will be use if provided.

expr1

Type: Stream or Function

Required. A stream or a function providing a stream.

expr2

Type: Stream or Function Default value: Stream.PassThrough

A stream or a function providing a stream.

Contributing / Issues

You may want to contribute to this project, pull requests are welcome if you accept to publish under the MIT license.

Authors

License

MIT

Keywords

FAQs

Package last updated on 11 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc