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

electrode-gulp-helper

v1.1.1

Published

Helper functions for using gulp

Downloads

202

Readme

electrode-gulp-helper NPM version Build Status Dependency Status

Helper functions for managing gulp tasks loading and executing.

Usage

Install:

npm install electrode-gulp-helper --save-dev
const gulpHelper = require("electrode-gulp-helper");

gulpHelper.loadTasks( tasks );

API

loadTasks

gulpHelper.loadTasks( tasks, gulp )

gulp - pass in gulp instance. If not provided, then it's attempted with require("gulp").

tasks - should follow the spec below:

{
    "task1-name": taskData,
    "task2-name": taskData
}

Where taskData can be a string, function, array, or object.

taskData

taskData specifies a task for gulp. It can be a string, function, array, or object.

string

If it's a string, then it's treated as a shell command and executed using exec.

function

If it's a function, then it's to be called by gulp when it executes the task. It's passed to gulp like this.

gulp.task( taskName, description, taskData );

The description support is added with the module gulp-help

If taskName starts with . then the description is false and disabled, else it's an empty string "". You can specify description if you use object for taskData.

array

If it's an array, it specifies a list of tasks or group of tasks in a subarray to be executed sequentially. A group of tasks will be executed in parallel.

Example: [ "task1", "task2", [ "p-task1", "p-task2" ], "task3" ]

task1 and task2 are executed in sequence first, and then p-task1 and p-task2 are executed in parallel, and finally task3.

The sequential execution support is from run-sequence.

The array is passed to run-sequence like this, with description being a stringified copy of the array.

gulp.task( taskName, description, () => {
    runSequence.use(gulp).apply(null, taskData);
});

object

If it's an object, it should follow this spec:

{
    name: "task-name",   // optional - use this instead of the key field for task name
    dep: array,          // optional - list of dependent tasks - follow definition above
    desc: "description", // optional
    task: string|function|array // follow the definitions above
}

If the description field desc is false, then the task is not listed in help. If it's undefined, then "" will be used.

The dep specified a dependent array of tasks following the array spec above, to be executed before the actual task. It is added to gulp like below, with a new delegate task using the same name with a postfix $deps$.

gulp.task( `${taskName}$deps$`, false, () => runSequence.use(gulp).apply(null, taskData.dep) );

exec

gulpHelper.exec( shellCommand, [callback] );

Use shelljs exec to execute shellCommand.

If callback is provided, it will be called as follows:

callback( code !== 0 ? new Error("...") : undefined, { stdout, stderr } )

stdout and stderr is also set in the error object.

If no callback is provided, it will return a Promise that rejects with the error or resolve with { stdout, stderr }.

shellCommand can be combination of multiple strings and arrays. Array is joined with " " into strings. All final strings are joined with " ".

envPath.addToFront

gulpHelper.envPath.addToFront(path);

Add path to the front of process.env.PATH. If it already exists, then it is moved to the front.

envPath.addToEnd

gulpHelper.envPath.addToEnd(path);

Add path to the end of process.env.PATH. If it already exists, then it is moved to the end.

envPath.add

gulpHelper.envPath.add(path);

If path doesn't exist in process.env.PATH then it's added to the end.

Built with :heart: by Team Electrode @WalmartLabs.