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-auto-task

v0.0.1

Published

Automatically create gulp tasks from node modules from a glob pattern.

Downloads

33

Readme

gulp-auto-task

Automatically create gulp tasks from node modules from a glob pattern.

Installation

npm install gulp-auto-task

Including

require('gulp-auto-task');

Usage

Simply call it as a function passing in your a glob pattern and an optional options object.

var gulp = require('gulp');
var gulpAutoTask = require('./build/lib/auto-task');

gulpAutoTask('{*,**/*}.js', {
    // This is prepended to the glob pattern and excluded from the task name.
    base: './build/gulp',

    // The gulp instance you want it applied to. If not specified this tries
    // to `require('gulp')` for you.
    gulp: gulp
});

And in ./build/gulp/my-task.js

module.exports = function myTask () {
  // do something tasky
};

Why?

Several reasons.

  1. All your tasks become true modules. No more gulp.task inside of your module.
  2. Since they're now just normal modules that export functions, they can be reused.
  3. Enforces usage of good, existing conventions.
  4. Finding a task is easy because it is based off the file path. No more "where the f**k is that task?" because it's nested in some file with a bunch of other tasks.
  5. Small gulpfile.
  6. Use something like https://github.com/pahen/madge to map your dependencies.

Defining Task Dependencies

You can define dependencies for a task in the normal, could-be-better, Gulp way using names. To do this, add a deps array to your task function:

function myTask () {
  // tasky task
}

myTask.deps = ['task1', 'task2'];

However, this is not recommended. Why you ask? Because:

  1. Want to find out why some task was run but it's not a direct dependency of the task you currently ran? Follow the dependency chain. Manually.
  2. Do you have multiple tasks per file? Good luck.
  3. Your tasks are run in parallel. Good for lots of things, but not everything.
  4. If you want to run your tasks in serial, you must go and return explicitly from the task. Wait now that task can't be reused to run in parallel.

If you don't mind those things, that's cool. It's there for you to use. But... there's a better way.

Using with mac

Mac gives you a way to chain a bunch of Gulp streams in parallel, or in series, using only the task function you've defined. The only thing you've got to make sure that you do is to return your stream from your task and it can be reused wherever.

Check out the build example for more information.