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

v0.3.0

Published

Provides Grunt like config support to gulp

Downloads

1,002

Readme

gulp-config

NPM version Build Status Dependency Status

gulp-config provides grunt like config management for gulp tasks.

Why

  • Even code sometimes needs a little config
  • Keep gulpfile small and lean
  • Modular task management
  • Portability

Caveates

  • only a partial implementation of grunt config management
  • more test coverage needed

Install

$ npm install --save-dev gulp-config

Usage

'use strict';

var gulp   = require('gulp'),
    config = require('./lib')(gulp);

config({

    paths: {
        source: ['./lib/**/*.js'],
        tests : ['./test/**/*.js']
    },

    jshint  : { lint : '<%=paths.source%>' },
    mocha   : { specs: '<%=paths.tests%>'  }

});

Example gulpfile.js

gulp-config will auto discover by default any tasks located in the nearest tasks directory. This directory can be changed by passing in options when first intializing gulp-config ( see options )

Take a look at this projects gruntfile and tasks directory for a working example.

config

When tasks are registered via gulp-config, all sub targets will be made available via the parent task name. So for example running > gulp jshint will run all jshint targets whilst > gulp jshint:foo will only run the foo target.

Config files can also reference other config values in the same manner as grunt, using the <%=key.name %> pattern.

{
    'plugin': {
        options 		: {}, 			// global options
        target_1: {
            options		: {}, 			// target options ( merged with global )
            src 		: ['some/path'],
            dest		: 'some/des'
        },
        target_2: ['some/path'],
        target_3: 'some/path',
        target_4: {
            files: {
                'dest/path': 'source/path'
            }
        }
    }

{

help

gulp-config can support gulp-help, when told to do so.

var gulp   = require('gulp'),
    helper = require('gulp-help'),
    config = require('gulp-config')(gulp, {
        help: true
    });

This allows more detail to be added to your config which will be exposed when you run > gulp help.

{
    aliases 		: ['foo'],  	// alias names for task
    description 	: '', 			// task description for help
}

Example help options

These options can be added to plugin or target keys. Note description can be set to either a string to override the default or a boolean. If you wish to hide a description in help set the value to false.

Options

When first initilizing gulp-config, an options object can be passed which can be used to customize where tasks are located.

tasks

This is used to set where tasks can be found. Passing a single path is supported, in addition an array of paths can also be specified. All paths support glob style matching.

Should you wish to not used auto lookup, tasks can be passed directly via an object literal.

For convenience, gulp-util is available automatically via gulp.util within a task.

Basic

var gulp   = require('gulp'),
    config = require('gulp-config')(gulp, {
        tasks: ['some/path/*/*.js', 'some/other/path/**/*.js']
    });

Advanced

var gulp   = require('gulp'),
    config = require('gulp-config')(gulp, {
        tasks: {
            jshint: function (gulp) {
                // my custom task
            }
        }
    });

tasks

Tasks registered via gulp-config should follow the pattern below;

module.exports = function (gulp /* , cb */) {

    var options = this.options({
            level: 'two'
        }),
        file  = this.file,   // object
        files = this.files;  // array

    // task code ......

    gulp.src(file.src)
        .pipe(someplugin(options))

};

Tasks registered in this manner will have access to a config object and a file object.

  • The config object, is the current targets options based upon a processed config.
  • The file object contains the current targets src and dest properties.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using gulp.

Release History

  • 0.3.0 Fix incorrect behavior of this.options() to use _.defaults
  • 0.2.4
    • tasks can access another tasks config via this.config()
    • added template interpolation via expander
    • added file.src expanding via node-configfiles
  • 0.2.3
    • restore gulp async behaviour
  • 0.2.2
    • removed task.help && target.help (task|target).description now toggles help display
  • 0.2.1
    • task scope fixes
    • this.files support added
  • 0.2.0
    • gulp-help is nolonger bundled, use options.help
    • this.config nolonger available
  • 0.1.5
    • added this.options()
    • deprecated this.config
  • 0.1.4 file.src fix
  • 0.1.3 Lack of sleep
  • 0.1.2 Expose main ( silly mistake )
  • 0.1.1 Revised documentation
  • 0.1.0 Initial release

License

Copyright (c) 2014 Jonathan Barnett. Licensed under the ISC license.