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-simpletask

v1.0.5

Published

A slightly cleaner way to use gulp tasks, with plumber and notify.

Downloads

19

Readme

gulp-simpletask

A simpler way to use gulp, with some default error handling and notifications.

task( name, file, action )
  • name - The name of the task, used to identify the task.
  • file - An object describing the src, dst and optional watch paths.
  • action - A function that returns an array of what is normally fed into pipe(...),

Here's an simple example:

var task = require('gulp-simpletask'),
    sourcemaps = require('gulp-sourcemaps'),
    autoprefixer = require('gulp-autoprefixer'),
    sass = require('gulp-sass');

task('scss',
    {
        src: [
            'src/css/theme.scss'
        ],
        dst: 'dist/css/',
        watch: 'src/css/**/*.scss'
    },
    () => [
        sourcemaps.init(),
        sass({
            sourceComments: false,
            outputStyle: 'compressed',
            precision: 4
        }),
        sourcemaps.write('.')
    ]);

All you need to do is simply call gulp on the command line, it automatically will use the tasks defined as the default set. Each task is backed by gulp-plumber and gulp-notify to handle and inform you of errors.

Its important to note that each task automatically watches the with gulp-watch. If the watch parameter is not given, the src parameter is used.

Hey, what if I just want to copy files to the destination?

This is what I used in one of my projects. Simply don't specify the action function.

task('extra',
    {
        src: [
            'src/**/*',
            '!src/!(js-lib)/**/*.js', // Ignore js, unless in the js-lib folder
            '!src/**/*.{html,scss,png,jpg,jpeg,gif,svg}', // Ignore all other files
        ],
        dst: 'dist/'
    });

But wait, how do I handle events?

Glad you asked, there is a way to be a bit more explicit about tasks.
For example with gulp-rollup and its bundle event.

Take note of the file argument, this is the parameter specified with src, dst, and watch,

var caches = {};
task('js',
    {
        src: [
            'src/js/index.js',
        ],
        dst: 'dist/js/',
        watch: 'src/js/**/*.js'
    },
    file => [
        // ... Stuff before
        {
            // Pipe call
            pipe: rollup({
                entry: file.src,
                // ... Config stuff
            }),
            // On events
            on: {
                bundle: (bundle, name) => {
                    caches[name] = bundle;
                }
            }
        },
        // ... Stuff after
    ]);

Ok, thats pretty neat... but how do I do X?

Well at this point its probably best to just use normal gulp as doing more elaborate things defeats the utility of this package.