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

preen

v1.2.0

Published

preen unwanted files in packages installed via Bower

Downloads

208

Readme

#Preen Analytics

A Node.js module to preen unwanted files and folders from packages installed via Bower.

Bower is great but some times it gives you more than you need. These days many packages define paths that are not required in production via the bower.json files ignore property but even then you may still get more than you need. Preens role is to remove any of those unwanted files/paths.

##A Basic Example My projects bower.json file has jquery as a dependency.

{
  "name": "myProject",
  "dependencies": {
    "jquery": "~2.0.3"
  }
}

which gives the following folder after running bower install

but all I really need for this project is the 4 javascript files. So I update my bower.json with a preen property as follows

{
  "name": "myProject",
  "dependencies": {
    "jquery": "~2.0.3"
  },
  "preen": {
    "jquery": [
      "*.js"
    ]
  }
}

and then run preen to end up with

###Updated Example The previous example will not work for newer versions of jquery such as 2.1.1 due to its updated folder structure

A more suitable bower.json would look like

{
  "name": "myProject",
  "dependencies": {
    "jquery": "~2.1.1"
  },
  "preen": {
    "jquery": [
      "dist/*.js"
    ]
  }
}

resulting in

##Configuration As shown above configuration is done via the preen property of your bower.json file. The preen data object expects properties for each bower installed package that is to be preened in the format

"<package>": ["<patern 1>", "<patern 2>", ...]

See Minimatch for an explanation of Minimatch patterns.

Any packages not listed will not be preened.

##Options when running via the command line you can add a preview flag to see a list of all paths and if they will be deleted or kept preen --preview

you can then run preen if you are happy to go ahead

A verbose flag is also avaible to show the same level of detail as the actual preen is run preen --verbose

You can also add a directory flag to override bower's default directory (or the one set in .bowerrc). This can be useful when using preen as part of your build pipeline. Example: preen --directory ./tmp/path/to/bower/root

##Grunt Task while preen can be run via the command line it is well suited to running as a grunt task NPM

##Gulp Task preen can also be used in a gulp task (there is no need for preen to have gulp plugin). The below example would run preen (with no options set) before the default task.

var gulp = require('gulp'),
preen = require('preen');

gulp.task('default', ['preen'], function() {
  // place code for your default task here
});

gulp.task('preen', function(cb) {
  preen.preen({}, cb);
});

##Dependencies thanks to the following modules that make this one possible

  • async
  • bower
  • fs.extra
  • readdirp
  • minimatch
  • optimist
  • winston

##Credits thanks to @brainboost, @ratbeard and @Taiters for their contributions

Release History

  • Aug 9, 2013 v1.0.0 preen and grunt-preen are ready to roll
  • Jun 20, 2014 v1.1.0
    • new --verbose flag
    • improved logging using winston
    • updated examples
  • Jul 14, 2014 v1.1.1
    • fixed callback not being called
  • Aug 1, 2014 v1.1.2
    • fixed bug causing incorrect deletion on windows
  • Nov 11, 2014 v1.1.3
    • fixed bug allowing execution to end before all async deletions complete
  • Jan 30, 2015 v1.2
    • new --directory flag