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

dir-snap

v0.3.0

Published

This compares the contents of a directory against a previous snapshot.

Downloads

13

Readme

dir-snap

dir-snap - A snappy directory snapshot tool

Greenkeeper badge Build Status Coverage Status

This module makes it easy to compare before and after snapshots of your project's filesystem. Simply use dirsnap to create a reference point (dirsnap reference), then make as many changes as you want. When you want to see what has changed, run a compare (dirsnap compare) and the files that have been altered will be displayed.

Installation

Install globally via npm:

$ npm install -g dir-snap

Or globally via yarn:

$ yarn global add dir-snap

Usage

Please note that the command to use in the CLI is dirsnap with no hypen.

Reference

reference is a very simple function that creates a snapshot of the current folder structure. Pass in a folder to begin searching through and an extension for the filetype you care about (dirsnap reference -f ./myProject -e js).

$ dirsnap reference -f [folder] -e <ext>

When the scanning has completed, a reference JSON file will be written in the .dirsnap folder of the project to be used later during a compare. This library currently uses the MD5 checksum of a file for comparison purposes.

NOTE: The filename will be ${extension}FileReference.json.

An example of the JSON structure looks like this:

{
    "cwd": "/Users/FakeUser/Git/dir-snap/test/testParent",
    "date": "2017-09-03T03:06:23.079Z",
    "ext": "js",
    "files": {
        "/Users/FakeUser/Git/dir-snap/test/testParent": {
            "javascript.js": "496dd81dea39fb0b0c07be50c2fc67a3",
            "javascript.min.js": "1d6a42d2095f51127215e64c5f67da11"
        },
        "/Users/FakeUser/Git/dir-snap/test/testParent/models": {}
    },
    "folder": "./",
    "store": "./"
}

Compare

compare scans through the folder passed in and produces an updated snapshot to compare with the latest reference file. Once the compare happens, a colorized diff will be logged for all files that have changed since the reference was made.

$ dirsnap compare -f [folder] -e <ext>
$ dirsnap compare -f ./my-project -e js

List

list will output all reference files that are for a specific folder. This makes it easy to check what reference files have been created and can be compared against.

$ dirsnap list -f [folder]
// Example output:
// EXT DATE                     FILE
// js  2017-09-03T03:07:24.079Z jsFileReference.json
// css 2017-09-03T03:06:23.079Z cssFileReference.json

Reset

reset will delete one or all reference files for a specific folder. Use if you need to start over or have made significant changes to the folder structure.

$ dirsnap reset -f [folder] -e [ext]

NOTE: If a folder is not passed in, this command will delete all reference files tied to the current working directory.

Specifying a reference directory

Sometimes the folder being examined is not the best location for the .dirsnap directory (e.g. running a test that deletes and then recreates a folder). In these cases, the store option can be utilized for the compare and reference commands to indicate which folder to store the reference files in.

$ dirsnap reference -f [folder] -e [ext] -s [referenceFolder]
$ dirsnap reference -f ./my-project -e js -s ./references

License

Copyright Lance Turri. Released under the terms of the MIT license.