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

v1.5.0

Published

Load gulp tasks from folder

Downloads

2,578

Readme

Gulp Task Loader

Organize your gulp-tasks in separate files

Dependency Status DevDependency Status PeerDependency Status Build Status

Not actively maintained

Because I rarely use gulp these days. Wanna take over? Tell me.

Install

npm install gulp-task-loader --save-dev

Use

  1. Create one file / task
  2. Place the task-files in a folder named 'gulp-tasks' (or whatever you like)
  3. Require this module and invoke it [with or without options]
  4. Gulp-tasks now magically exist (named after task file name)

You may create subfolders of tasks as well. Tasks in these folders will have their task name prefixed by the folder name. For example, if you have a task named coffee that compiles CoffeeScript files, you could place this task in the gulp-tasks/browser folder and it would be invoked using gulp browser:coffee. You may nest folders as deep as required, and each folder will be added to the task name.

Examples

Simple task file

// gulp-tasks/copy.js
module.exports = function() {
	return gulp.src("src/**/*")
		.pipe(gulp.dest("dist/**/*"));
};
// gulpfile.js
// Load all tasks from folder `gulp-tasks`
require('gulp-task-loader')();

// use it!
gulp.watch(someFiles, ['copy']);

With dependencies

// gulp-tasks/task-with-deps.js
module.exports = function() {
    return gulp.src("src/**/*")
        .pipe(gulp.dest("dist/**/*"));
};
module.exports.dependencies = ['copy'];

Load tasks from another folder

require('gulp-task-loader')('le-tasks-de-gulp');

Load tasks in CoffeeScript

require('coffee-script/register');
require('gulp-task-loader')({ exts: ['.coffee'] });

Load tasks in other extensions

require('gulp-task-loader')({ exts: ['.jscript'] });

Task context

Each task is called with a context object containing a reference to gulp and opts (the options object).

// gulpfile.js
var pkg = require('./package.json');
require('gulp-task-loader')({ pkg: pkg, dest: 'dist' });

// gulp-tasks/xxx.js
module.exports = function() {
    return this.gulp.src(this.opts.pkg.main)
      .pipe(this.gulp.dest(this.opts.dest));
};

Subtasks

// gulp-tasks/copy/all.js
// gulp-tasks/copy/fonts.js

// gulpfile.js
gulp.watch(allFiles, ['copy:all']);
gulp.watch(someFiles, ['copy:fonts']);

Given the files in folder copy - two tasks have been created. copy:all & copy:fonts

Options

dir

Type String Default gulp-tasks

Path to folder with gulp tasks

extensions

Type Array Default to keys of require.extensions

List of extensions to filter tasks by. Example: ['.js', '.coffee']

Test

npm test

Changelog

1.4.4

  • Bugfix for options.dir

1.4.1

  • Fixed bug that caused subtasks to break

1.4.0

  • Allow loading of infinitely nested children directories

1.3.0

  • Replaced lodash.defaults with object-assign
  • Call tasks with context. Thanks to @mamboer

1.2.1

  • Load tasks relative to project. Thanks to @archr

1.2.0

  • tasks in subfolder will be named folderName:taskName. Thanks to @evanshortiss.

1.1.0

  • added support for other sources than .js. Thanks to @blvz.

pre 1.1.0

  • the dark ages of not documenting version bumps..