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

globfs

v0.5.0

Published

Glob oriented file system operations, extending fs package

Downloads

9

Readme

globfs

Useful functions for dealing with files, selecting them by "glob" patterns.

This Node.js module is an addon to the 'fs' module allowing the programmer to select files using glob patterns, acting on those files.

Installation

npm install --save globfs

This gives you both a command-line tool, documented below, and a Node.js API, documented here: http://robogeek.github.io/globfs/

Installed as shown above, npm installs the command as ./node_modules/.bin/globfs. For convenience you should add the path node_modules/.bin to your PATH so that commands associated with Node.js modules are easily executed.

  • Bash: in $HOME/.profile add this line: export PATH="./node_modules/.bin:${PATH}
  • csh: in $HOME/.cshrc add this line: setenv PATH ./node_modules/.bin:$PATH
  • Windows: TBD

The globfs command is invoked this way:

$ globfs --help

  Usage: globfs [options] [command]


  Commands:

    find <srcdir> [patterns...]                      Find files based on the pattern(s)
    copy [options] <srcdir> <destdir> [patterns...]  Copy stuff from one directory to another
    rm [options] <dir> [patterns...]                 Delete stuff in a directory
    chmod [options] <dir> <newmode> [patterns...]    Change permissions of stuff in a directory
    chown [options] <dir> <uid> <gid> [patterns..]   Change ownership of stuff in a directory
    du [options] <dir> [patterns..]                  Disk utilization of stuff in a directory

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

For each of the commands you can run globfs commandName --help to get help for that command.

The commands should be self-explanatory, but here's a few examples

$ globfs find node_modules/ '**/*.css'
[ { basedir: 'node_modules/',
    path: 'akashacms-embeddables/assets/vendor/Viewer.js/example.local.css',
    fullpath: 'node_modules/akashacms-embeddables/assets/vendor/Viewer.js/example.local.css',
    result: 'akashacms-embeddables/assets/vendor/Viewer.js/example.local.css' },
  { basedir: 'node_modules/',
    path: 'akashacms-theme-bootstrap/bootstrap/bootstrap3/css/bootstrap-theme.css',
    fullpath: 'node_modules/akashacms-theme-bootstrap/bootstrap/bootstrap3/css/bootstrap-theme.css',
    result: 'akashacms-theme-bootstrap/bootstrap/bootstrap3/css/bootstrap-theme.css' },
  { basedir: 'node_modules/',
    path: 'akashacms-theme-bootstrap/bootstrap/bootstrap3/css/bootstrap-theme.min.css',
    fullpath: 'node_modules/akashacms-theme-bootstrap/bootstrap/bootstrap3/css/bootstrap-theme.min.css',
    result: 'akashacms-theme-bootstrap/bootstrap/bootstrap3/css/bootstrap-theme.min.css' },
  ... ]

The find command is useful for finding files.

$ globfs copy node_modules node_modules_css '**/*.css'

$ du -sk node_modules node_modules_css
44364   node_modules
1068    node_modules_css

You can copy selected files from a directory hierarchy, preserving the hierarchy. In this case we selected just the CSS files, proved by the disk consumption of the resulting directory tree.

$ globfs copy node_modules node_modules_cssjs '**/*.css' '**/*.js'

$ du -sk node_modules node_modules_css node_modules_cssjs
44364   node_modules
1068    node_modules_css
30044   node_modules_cssjs

We can add a second file pattern to copy the JavaScript files, and see that the second directory tree, containing both CSS and JS files, is much bigger.

$ globfs rm node_modules_cssjs '**/*.js'

$ du -sk node_modules node_modules_css node_modules_cssjs
44364   node_modules
1068    node_modules_css
1064    node_modules_cssjs

The rm command deletes selected files. Deleting the JavaScript files from the previously created directory brings it close in size to the CSS-only directory tree.

$ globfs rm node_modules_cssjs

$ du -sk node_modules node_modules_css node_modules_cssjs
44368   node_modules
1068    node_modules_css
0       node_modules_cssjs

For all the commands, specifying zero glob patterns means the operation works on every file in the hierarchy. In this case we deleted everything under the directory, leaving it consuming 0 bytes.

$ globfs du node_modules '**/*.css'
782248
$ globfs du node_modules_css '**/*.css'
782248

Remember that the second directory was created by copying all CSS files from the first. It stands to reason, then, that these two commands tells us an identical figure for disk consumption.