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

v1.0.0

Published

gulp-task-file-loader - Loading gulp tasks from module files and using JSON to describe dependencies.

Downloads

40

Readme

gulp-task-file-loader

Loading gulp tasks from module files and using JSON to describe dependencies.

usage

  1. Install the package npm install --save-dev gulp-task-file-loader.

  2. Create a tasks directory and put some task file into it. A task file is a node.js module, which contains a gulp task.

    e.g. tasks/copy-files.js

    var gulp = require("gulp");
    module.exports = function () {
        return gulp.src("src/*")
            .pipe(gulp.dest("dest"));
    };

    or tasks/clean.js

    var del = require("del");
    module.exports = function () {
        return del(["dest"]);
    };
  3. Create a gulpfile.js in the project root which loads the tasks using a glob pattern.

    var loader = require("gulp-task-file-loader");
    loader("tasks/*");

    And that's all, your tasks will be loaded! :-)

    The non-javascript files will be automatically filtered out so you don't have to worry about them.

    If you want to use the glob with options, e.g. glob.sync(pattern, options), then you have to pass an array as first parameter.

    loader(["tasks/**/*.js", {debug: true, strict: true}]);
  4. When your tasks are dependent on each other you can create a dependency descriptor JSON file.

    e.g. tasks/deps.json

    {
        "copy-files": ["clean"]
    }

    In this case the copy-files task is dependent on the clean task, since it has to wait until the old files are deleted from the dest directory before copying the new files to it.

    You can load this JSON file by passing the file name to the loader.

    loader("tasks/*.js", "tasks/deps.json");

    or you can use a javascript object instead of a JSON file if that's what you prefer

    loader("tasks/*.js", {
        "copy-files": ["clean"]
    });

    When you have a root task, which only concerns about pulling in dependencies, then you don't have to create a dummy task file. Adding the task to the dependencies is enough.

    e.g. by gulp build

    loader("tasks/*.js", {
        "build": ["copy-files"],
        "copy-files": ["clean"]
    });
  5. Enjoy! :P

testing

I was lazy to write tests. Sorry for that! Maybe I'll do it later. (or not) xD

limitations

The only limitation currently that the task name generation is hardcoded var name = path.basename(file, ext);. Which means that you cannot have two files with the same basename, because that would cause a task name duplication error. For example if you have a pattern like tasks/**/*.js and you have task files like tasks/clean.js and tasks/subtask/clean.js, then the clean task name would be used twice. If you have a better strategy to generate task names, then please contribute!

contribution

If you have any ideas about further enhancements, then please open an issue or send a pull request!

license

MIT - 2015 J�nszky L�szl� Lajos