Skip to content

Instantly share code, notes, and snippets.

@lavelle
Created September 13, 2018 21:32
Show Gist options
  • Save lavelle/8ccb41ab4829b408b4a857b59e1230bf to your computer and use it in GitHub Desktop.
Save lavelle/8ccb41ab4829b408b4a857b59e1230bf to your computer and use it in GitHub Desktop.
const fs = require('fs');
const path = require('path');
const _ = require('lodash');
const globby = require('globby');
const glob = '{components,modules,pages,utilities,globals,bundles,legacy-js}/**/*.{js,jsx}';
const stats = JSON.parse(fs.readFileSync(path.join(__dirname, 'stats.json')));
const entryFilter = x => /jsx?$/.test(x) && !/node_modules/.test(x);
const resolver = filePath => path.resolve(__dirname, filePath);
const testStoriesFilter = x => /(stories|test|fixture)(\.es6)?\.jsx?$/.test(x);
const filesInDepGraph = _.map(_.filter(_.map(stats.modules, 'id'), entryFilter), resolver);
const filesInRepo = _.map(globby.sync(glob), resolver);
const actualFilesOnly = _.reject(filesInRepo, testStoriesFilter);
const diff = _.difference(actualFilesOnly, filesInDepGraph);
console.log(JSON.stringify(diff, null, 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment