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

directory-fixture-provider

v1.7.28

Published

Provides directories for testing.

Downloads

14

Readme

QA dsl-toolkit

CI Maintainability Test Coverage FOSSA Statuslerna

Installation

npm install directory-fixture-provider --save-dev

Motivation

..comes to write something like this, when your library that work with files and directories and you want to test the results.

Usage

Directory-fixture-provider has its own limited DSL that gives you a few options for now, but can be handy to know about.

Basics

const fixturesRoot = '/paht/to/your/fixture/directories/files'
/*
contains files and direcories for examnple:
- file-a.js
- file-b.js
- directory1/file-c.js
- directory2/contains-a-lot-of-files.js
- directory2/directory3/contains-a-lot-of-files-as-well.js

*/
const dfp =  require('directory-fixture-provider')
const fixtureDirectoryProvider = dfp(fixturesRoot)()
const fixtureData = fixtureDirectoryProvider.get('directory2')

// fixtureData contains an object where
/*
{ dir: '/tmp/directory-fixture-provider-destination/KzXwBFDdtAmh/',
  fixturePath: '/home/it/dev/misc/dsl-toolkit/packages/directory-fixture-provider/tests/directory-fixtures/',
  getFixtureFiles: [Function: getFixtureFiles],
  getDestinationFiles: [Function: getDestinationFiles],
  getStatus: [Function: getStatus],
  getFixtureContent: [Function] }
}
 */

This is how you start working with the tool, but the real fun starts. So you receive all files and subdirectories of the fixtures that subset what you were requesting too so in the example above the directory2 will be given back.

We have a random part of the path that is unique per fixture provider, so if you need clean data, create another directory-fixture-provider.

Sometimes you need it play more deterministic

Imagine a situation, when you are testing a small application that uses your framework, and you want to test your frameworks behaviour in the wild. In this case, you have your sample application, and you want to have installed its the dependencies, but the package.json does not change too often. In this case, it was nice overwriting the files, so you don't need that random part in the deployed directory.

const fixtureDirectoryProvider = dfp(fixturesRoot)('permanent')()

If you like the concept that your temporary files are in a fixed place, but rather you would empty the destination directory first you type: const fixtureDirectoryProvider = dfp(fixturesRoot)('permanent','cleanFirst')()

Check if your data has changed

const fixtureDirectoryProvider = dfp(fixturesRoot)()
const fixtureData = fixtureDirectoryProvider.get('./')
const fixtureDir = fixtureData.dir
// Work with the files
// add/remove/modify files, and you will get relevant info about them

fixtureData.getStatus().changed

// true if something is changed.

changeTotals

fixtureData.getStatus().changeTotals

// gives you the number of files changed

If a new file is added, deleted or an existing changed each count as a change here.

changeNumbers

fixtureData.getStatus().changeNumbers

/*
Returns an object like this:
{
  deleted: 0
  changed: 0
  new: 0
}
 */

Where it tells you how many files changed, deleted or new

If a file is deleted it will increase the changed data tag too.

Milestones

Create an excellent diff module for the getStatus resulting object.

More information

This library helps you find changes modifications between your working and original fixture files. More examples are coming for more information, please check the tests