npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-count

v1.0.0

Published

count files in vinyl streams

Downloads

9,364

Readme

gulp-count npm CircleCI

Count files in vinyl streams. Log pretty messages.

gulp-count in action

This plugin solves a similar problem to gulp-debug but is designed as an actual permanent part of your workflow, not just a debug tool (though it still makes a great debug tool!). As such, it provides more control over logging to customize as needed.

Usage

First, install gulp-count as a development dependency:

> npm install --save-dev gulp-count

Then, add it to your gulpfile.js:

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

gulp.task('copy', function() {
    gulp.src('assets/**.*')
        .pipe(gulp.dest('build'))
        .pipe(count('## assets copied'));
});

API

gulp-count can be called with a string message template, an options object, or both.

gulp.src('*.html')
    .pipe(count()) // logs "36 files"
    .pipe(count('<%= counter %> HTML files'))  // logs "36 HTML files"
    .pipe(count('found ## pages', {logFiles: true})) // logs each path and "found 36 pages"
    .pipe(count({
        message: '<%= files %>? That\'s ## too many!'
        logger: (msg) -> alert(msg) // alerts "36 files? That's 36 too many!"
    });

count(options?)

count(message, options?)

options.message: boolean | string = "<%= files %>"

Template string for total count message, passed through gutil.template.

Template can use two variables:

  1. counter - the number of files encountered in this stream,
  2. files - a correctly pluralized string of the format "X file[s]" where X is counter.

The template also expands the shorthand "##" to "<%= counter %>".

An explicit false value will disable the message (use logFiles or logEmpty instead).

options.logFiles: boolean | string = false

Whether to log each file path as it is encountered. options.cwd determines base path for logging.

If a string is provided then it is used as the message template. Template receives two variables:

  1. file - the current Vinyl file instance
  2. path - file path resolved relative to options.cwd and colored yellow.
options.logEmpty: boolean | string = false

Whether to log the message when the stream is empty.

If a string is provided then it is used as the message template and receives the same variables as options.message.

Setting { message: false, logEmpty: true } will log if and only if the stream is empty.

options.title: string

String prepended to every message to distinguish the output of multiple instances logging at once. A falsy value will print nothing.

options.cwd: string = ""

Current working directory against which file paths are resolved in template strings.

options.logger: (message) => any = gutil.log

Logger function, called with each formatted message. Defaults to gulp-util's log(msg...) function.

License

MIT © Palantir Technologies