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-load-all-tasks

v0.2.0

Published

Gulp task loader for Gulp 4.0+

Downloads

297

Readme

gulp-load-all-tasks

NPM version Build Status Dependency Status Coverage percentage

One folder, all tasks.
Inspired by gulp-task-loader.

Getting Started

Prerequisites

Please make sure you're using gulp version 4.0 or follow this guildline to upgrade.

Use NPM.

npm install -g gulp-cli
npm install --save-dev gulpjs/gulp#4.0

Use Yarn. (Installation)

yarn global add gulp-cli
yarn add --dev gulpjs/gulp#4.0

Check your gulp version.

gulp -v

You might get result like this:

CLI version 1.4.0
Local version 4.0.0-alpha.2

Install

By NPM:

npm install --save-dev gulp-load-all-tasks

By Yarn:

yarn add --dev gulp-load-all-tasks

Usage

  1. Create a folder named 'gulp-tasks' or whatever you like.
  2. Create a task definition file.
  3. Require this module and invoke it.
  4. All tasks are loaded.

You can also create subfolders to organize your tasks as sub-tasks. All sub-tasks will named with prefix by folder name.

For example, if the structure of your gulp-tasks are:

.
├── build
│   ├── pug.js
│   └── sass.js
├── build.js
├── watch.js
└── deploy.js

And you'll see your tasks list:

gulp --tasks

Tasks for guipfile.js
├── build:pug
├── build:sass
├── build
├── deploy
└── watch

Examples

Task definition file

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

// Run the task
gulp.task('default', gulp.series('copy', (done) => {
  console.log('Task done');
  done();
}))

Task with dependencies

// gulp-tasks/copy.js
const del = require('del');

module.exports = function() {
  return gulp.src('src/**/*')
    pipe(gulp.dest('dist/**/*'))
};
module.exports.dependencies = gulp.series('clean');

Load tasks by default folder

require('gulp-load-all-tasks')();

Load module by gulp-load-plugins

const $ = require('gulp-load-plugins')();
$.loadAllTasks();

Load tasks by Different folder name

require('gulp-load-all-tasks')('my-tasks');

Load tasks in other extensions

require('gulp-load-all-tasks')({
  exts: ['.coffee'],
});

Task context

Each task will binding a context object with reference to gulp and context.

// gulpfile.js
const browserSync = require('browser-sync').create();
require('gulp-load-all-tasks')({
  browserSync,
});

// gulp-tasks/pug.js
const $ = require('gulp-load-plugins')();

module.exports = function() {
  const gulp = this.gulp;
  const browserSync = this.context.browserSync;

  return gulp.src('src/pug/**/*')
    .pipe($.pug())
    .pipe(gulp.dest('dist')
    .pipe(browserSync.stream());
};

Forward Reference Support

If you got the error:

AssertionError: Task never defined: <task>

All the tasks are loaded by gulp alphabetically, it'll cause some of your task dependencies are loaded before it defined.

You can add undertaker-forward-reference as your gulp task registry.

const ForwardReference = require('undertaker-forward-reference');
const loadAllTasks = require('gulp-load-all-tasks');

gulp.registry(new ForwardReference());

loadAllTasks({
  // Context...
});

Options

dir

Type: String

Default: gulp-tasks

Folder path with all task files.

extensions

Type: Array

Default: ['.js']

Task file extensions.

License

MIT © ethancfchen