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

v0.1.5

Published

A gulp plugin for transforming file paths in the stream

Downloads

12

Readme

gulp-rename2

A simple, yet powerful gulp plugin for transforming file paths in the stream.

Usage

Here is a contrived example of transforming app/modules/viewer/index.coffee to .build/modules/viewer/index.js. Obviously, you may do anything you want inside pathObj.join() as long as it returns syntactically valid file path (i.e. no checks are made against the files system whether this path is valid or not).

var rename = require("gulp-rename2");

gulp.src("app/modules/viewer/index.coffee")
  .pipe(rename(function (pathObj, filePath) {
    return pathObj.join(
      // remove leading 'app/' directory from the file path
      pathObj.dirname(filePath).replace(/^app\/?/,''), 
      // replace '.coffee' file extension with '.js'
      pathObj.basename(filePath, '.coffee') + '.js'
    );
  }))
  // output to '.build' directory
  .pipe(gulp.dest('.build')); // .build/modules/viewer/index.js

API

rename(transformFunction [, options])

transformFunction

The transformFunction must have the following signature function (pathObj, filePath) {}. The pathObj is an instance of the core Node.js Path module and the filePath is the relative file path of the file piped through the stream. Basically, use pathObj instance to perform transformations on the filePath leveraging methods provided by the Node's Path core module.

This function must return the final path string.

[options]

{ verbose: true }

Use verbose option to output the original and the transformed file paths to the log. The default is false.

var rename = require("gulp-rename2");

gulp.src("app/**/*.coffee")
  .pipe(rename(function (pathObj, filePath) {
    return pathObj.join(
      // file path transformations
      ... ... ...
    );
  }, { verbose: true }))
  .pipe(gulp.dest('.build'));

License

MIT License