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

glupost

v4.1.0

Published

Build your gulp tasks from a configuration object.

Downloads

20

Readme

glupost

Build your gulp tasks from a configuration object.

Usage

Running

gulp start

with a gulpfile.js

// Transforms/plugins.
let toc = require("gulp-markdown-toc")()
let marked = (contents, file) => require("marked")(contents)


// Build tasks.
let tasks = {
   "md-to-html": {
      src: "src/docs/*.md",
      rename: {extname: ".html"},
      transforms: [toc, marked],
      watch: true
   },
   "start": {
      series: ["md-to-html", "watch"]
   }
}

let options = {
   template = {
      base: "src/",
      dest: "dist/"
   }
}

// Build the actual tasks.
let glupost = require("glupost")
module.exports = glupost(tasks, options)

and a file structure

├── src/
│   ├── docs/
│   │   ├── Getting started.md
│   │   ├── API.md
│   │   ├── Guidelines.md
│   │   └── Examples.md

would run start, that is, md-to-html and watch in series, producing

├── dist/
│   ├── docs/
│   │   ├── Getting started.html
│   │   ├── API.html
│   │   ├── Guidelines.html
│   │   └── Examples.html

once initially, and again on every file change.

API

glupost(tasks[, options])

Return an object containing gulp tasks ready for registration.

tasks » object declaring the tasks, invoked by gulp <task>.

options.template » object serving as a base for tasks with .src.

options.beep » boolean controlling if a beep sound is played once all watch-triggered tasks execute. false by default.

options.register » boolean controlling if tasks are registered to gulp or not. false by default.


Declaration of a task takes one of the following forms:

{
   // Name of another task.
   "alias": "another task",

   // Function.
   "sync callback": () => {},
   "async callback": (done) => done(),
   "async promise": async () => {},

   // Task object.
   "vinyl stream task": {
      src: "path",
      dest: "."
   },
   "wrapped": {
      task: () => {}
   },
   "tasks in series": {
      series: [...]
   },
   "tasks in parallel": {
      parallel: [...]
   }
}

A composition task object accepts one of:

.task » wrapper around a task, useful for {watch: "path", task: () => {}}.

.series » passed to gulp.series(), but also accepts task objects.

.parallel » passed to gulp.parallel(), but also accepts task objects.

A Vinyl stream task object (and options.template) accepts:

.src » string passed to gulp.src() to start the stream or a Vinyl file.

.dest » passed to gulp.dest() to output the files. Defaults to gulp's working directory.

.base » passed as base option to gulp.src().

.rename » passed to gulp-rename prior to writing.

.transforms » array of transform functions that receive file.contents and file parameters and must return a Vinyl file or its contents directly (as string or buffer), or a promise that resolves with one of those.

// Return string directly.
function copyright(contents) {
  return contents + "\nCopyright © 2017"
}

// Return Vinyl file.
function copyright(contents, file) {
  let suffix = Buffer.from("\nCopyright © 2017")
  file.contents = Buffer.concat(contents, suffix)
  return file
}

// Return promise.
async function copyright(contents) {
  return contents + "\nCopyright © 2017"
}

All task objects accept:

.watch » paths used by gulp.watch() to trigger the task. If set to true, the task's .src will be watched. All watchers are invoked by the generated watch task.