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

gulpplug

v1.4.0

Published

A small wrapper for gulp, that requires tasks from files and auto-loads gulp plugins.

Downloads

1

Readme

gulpplug

A toolkit for gulp, which can require task files, auto-load gulp plugins and offer some sugar.

gulpplug

npm Package Version MIT License Travis Build Status

Dependencies Status devDependencies Status Code Climate GPA Code Climate Test Coverage


README IN PROGRESS

About gulpplug

gulpplug's main purpose is to glob some files and require them to create gulp tasks. This way you can organize your tasks in multiple files and folders. You can also define task descriptions from which gulpplug can create a help task listing all available tasks.

Within your task function context you can access your current instance of Plug, gulpplug's main class, via this and find gulp at this.gulp. gulpplug also offers gulp-util (this.util), run-sequence (this.runSequence) and your gulp plugins (this.plugins), which can be auto-loaded using auto-plug.

Install

gulpplug doesn't include gulp and is useless without it, so you obviously have to install both. Use npm:

npm i -S gulp gulpplug

Quick Start

Your Gulpfile.js could look like this:

var gulp = require('gulp'),
    plug = require('gulpplug')(gulp);

plug.loadPlugins()
    .addTasks()
    .addHelpTask();

Let's say, you want to create a gulp task called minify to pipe some javascript files through gulp-uglify, which you have installed as dependency.

Go ahead and create the file .gulpplug/minify.js containing:

module.exports = function() {
    return this.gulp.src('./src/*.js')
        .pipe(this.plugins.uglify())
        .pipe(this.gulp.dest('./dist'));
}

Usage

Create your Plug instance

Plug is gulpplug's main class. It needs your current gulp instance as first argument and accepts an options object as second argument.

You can create your Plug instance by calling the required main function…

var gulp = require('gulp'),
    plug = require('gulpplug')(gulp);

…or require the class definition and call new:

var gulp = require('gulp'),
    Plug = require('gulpplug').Plug
    plug = new Plug(gulp);

Options

gulpplug looks for a folder called .gulpplug/ in the same directory where your Gulpfile.js is.

See also example/.

Defining Tasks

All files matching **/*.js within .gulpplug/ will be required and should return a function to create a task.

For example, .gulpplug/foo.js will be executable via gulp foo and could look like this:

module.exports = function() {
    return this.gulp.src(…)
        .pipe(this.plugins.someGulpPlugin())
        .pipe(this.gulp.dest(…));
    });
};

this is your current Plug instance, delivering gulp, gulp-util and run-sequence as properties. (As well as other properties and methods you may want to use - take a look at the sourcecode.)

module.exports = function(done) {
    this.util.log(this.chalk.green('Starting async things…'));
    setTimeout(function() {
        this.util.log(this.chalk.red('Async stuff done.'));
        done();
    }.bind(this)), 100);
};

You can organize your task files in subfolders.
For example, this will add the tasks foo and bar:baz:

my-project/
 ├─╸ .gulpplug/
 │    ├─╸ bar/
 │    │    └─╸ baz.js
 │    └─╸ foo.js
 └─╸ Gulpfile.js

Help task and descriptions

You can add a automatically generated help task by calling plug.addHelpTask().

Run the task via gulp help. It will show all available tasks with a description if available.

Add a task description:

module.exports = [
    'this task does awesome stuff',
    function() {
        …
    }
];

Loading gulp plugins

By calling plug.loadPlugins(), auto-plug will be used to load gulp plugins defined in your project's package.json. You can set auto-plug options as first argument.

Plug Class

By calling require('gulpplug')(…) you get a new instance of Plug, which expects gulp as first argument and an optional options object as second argument.

You can also access the class directly.

var path = require('path'),
    gulp = require('gulp'),
    Plug = require('gulpplug').Plug,
    plug = new Plug(gulp, {
        cwd: path.dirname(__filename),
        tasksDir: 'my-gulp-tasks'
    });

License

MIT © 2015 Simon Lepel