Created
September 13, 2018 21:32
-
-
Save lavelle/8ccb41ab4829b408b4a857b59e1230bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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