JSPM

missing-files

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q26335F
  • License MIT

Compare two directories and return files not found in second directory

Package Exports

  • missing-files

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (missing-files) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

#missing-files

Nodejs function to compare two directories and return files not found in second directory. Useful for ensuring that all files have matching test files, however having a file does not mean it's tested!

##Installation

npm install missing-files

##Usage missingFiles(masterDir, compareDir, excludes, callback)

  • masterDir : directory to be compared against (i.e. source)
  • compareDir : directory that 'should' match (i.e. tests)
  • excludes: array of regex/string to filter results
  • callback: function(error, result)

##Usage in a test

test('ensure that all source files have matching test file', function(t) {
    t.plan(1);

    var sourceDir = path.resolve(__dirname,  '../lib'),
        testDir = path.resolve(__dirname, '.'),
        excludes = [
            /^\myprotectedpath\//,
            /^\/models\//,
            '.DS_Store',
            /(.*).json/
        ];

    missingFiles(sourceDir, testDir, excludes, function(error, result) {
        t.deepEqual(result, [], 'all files are covered');
    });
});

Pull requests welcome