diff --git a/bin/build.js b/bin/build.js index d313c8c..b7e6309 100644 --- a/bin/build.js +++ b/bin/build.js @@ -45,13 +45,13 @@ function finish () { new Report({ title: 'Top Dependencies in Apps', description: 'npm packages that are used most often as `dependencies` in Electron apps', - collection: topDeps.map(package => pick(package, desirablePackageProps)) + collection: topDeps.map(pkg => pick(pkg, desirablePackageProps)) }).save() new Report({ title: 'Top Development Dependencies in Apps', description: 'npm packages that are used most often as `devDependencies` in Electron apps', - collection: topDevDeps.map(package => pick(package, desirablePackageProps)) + collection: topDevDeps.map(pkg => pick(pkg, desirablePackageProps)) }).save() new Report({ @@ -64,7 +64,7 @@ function finish () { title: 'Electron-specific packages most-depended-on by other npm packages', description: 'Electron-specific npm packages that are depended on by other npm packages', collection: electronNpmPackages - .map(package => pick(package, desirablePackageProps)) + .map(pkg => pick(pkg, desirablePackageProps)) .map(utils.convertDepListToCount) .sort((a, b) => b.totalDeps - a.totalDeps) .slice(0, MAX_RESULTS) @@ -74,7 +74,7 @@ function finish () { title: 'Most-downloaded Electron-specific npm Packages', description: 'Electron-specific npm packages that are depended on by other npm packages', collection: electronNpmPackages - .map(package => pick(package, desirablePackageProps)) + .map(pkg => pick(pkg, desirablePackageProps)) .map(utils.convertDepListToCount) .sort((a, b) => b.downloadsInLastMonth - a.downloadsInLastMonth) .slice(0, MAX_RESULTS) diff --git a/index.js b/index.js new file mode 100644 index 0000000..16a7edf --- /dev/null +++ b/index.js @@ -0,0 +1,6 @@ +const fs = require('fs') +const path = require('path') +const Report = require('./lib/report') +const basepath = path.join(__dirname, 'reports') +module.exports = fs.readdirSync(basepath) + .map(basename => new Report(require(path.join(basepath, basename)))) diff --git a/lib/utils.js b/lib/utils.js index 4b16d91..40c4e54 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -21,15 +21,15 @@ module.exports = { return tally(cleanNames(names), 'user', 'repos') }, - convertDepListToCount: (package) => { - if (Array.isArray(package.dependents)) { - package.dependents = package.dependents.length + convertDepListToCount: (pkg) => { + if (Array.isArray(pkg.dependents)) { + pkg.dependents = pkg.dependents.length } - if (Array.isArray(package.devDependents)) { - package.devDependents = package.devDependents.length + if (Array.isArray(pkg.devDependents)) { + pkg.devDependents = pkg.devDependents.length } - return package + return pkg } }