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-inheritance

v0.0.3

Published

Gulp plugin to emit the files that depend on the input files

Downloads

1

Readme

gulp-inheritance

A gulp plugin for dependency-resolution. There are several options out there, but none of those that I found were a good fit for my gulp setup. Some work like grunt plugins (i.e. they actually work on the file system), others have distinctly different use-cases.

gulp-inheritance does only a few things, and leaves everything else up to you:

  • searches all incoming files for dependency references based on a regular expression or a matcher function, and builds a dependency graph from that information
  • emits files based on that dependency graph

Install

npm install gulp-inheritance --save-dev

Usage

Simple example:

gulp.src('src/styles/**/*.scss')
.pipe(gulpInheritance({extract: /@import '(.+)';/g}))
.pipe(process()) // whatever you want to do with the files
.pipe(gulp.dest('dev'))

Complex example:

gulp.src('src/styles/**/*.scss')
.pipe(preProcess())
.pipe(gulpInheritance({
  includeAll: true,
  extract: /@import '(.+)';/mg
  normalizePath: customNormalization,
  originalPaths: true
}))
.pipe(sass())
.pipe(postProcess())
.pipe(gulp.dest('dev'))

The two examples above show the plugin's minimum and maximum supported setup. It should be clear, on account of that simplicity, that you can use the plugin for any file format.

The examples apply to SCSS files, but that's just for illustration. gulp-inheritance is intentionally devoid of language-specific knowledge in order to keep it lean. You can, of course, easily create derivative plugins that contain said knowledge.

Options

extract [required]

This can be either a regular expression (or string) matching the pattern of dependency declaration used, or a function.

  • Regular Expression: Should be pretty straight-forward. Just be aware that, should you want to match line delimiters (/^$/), you need the m flag. Also, do not forget the g flag. The first matching group will be used as dependency path – either relative to the depending file's own path, or absolute.
  • String: Will be converted to a regular expression, with global and multiline flags set.
  • Function: Will be given the input file as its only argument and must return an array of strings.

includeAll [default: false]

  • True: All input files and all depending files will be emitted.
  • False: Will emit only those files that are no dependencies for any other files.

normalizePath [default: path.resolve]

You can give a function for custom path normalization here. E.g. with SCSS imports, you'll want to remove the underscore from partials in order for them to be properly identified.

Applies to both incoming files and their dependencies.

originalPaths [default: false]

  • True: Use the original file system path for each file.
  • False: Use the current, potentially transformed, file path.

This is useful if you perform any transformations on your files' paths prior to applying this plugin.

License

ISC