Skip to content

Instantly share code, notes, and snippets.

@pastak
Created June 6, 2017 12:10
Show Gist options
  • Save pastak/8fd7eae48492090b5d19df95a8a16dba to your computer and use it in GitHub Desktop.
Save pastak/8fd7eae48492090b5d19df95a8a16dba to your computer and use it in GitHub Desktop.
const fs = require('fs');
const path = require('path');
const rootPackageJson = JSON.parse(fs.readFileSync(path.resolve('./package.json')));
const dependencies = Object.assign(rootPackageJson.dependencies, rootPackageJson.devDependencies);
const nodeModulelDirs = fs.readdirSync(path.resolve('./node_modules'));
nodeModulelDirs
.filter((name) => !!dependencies[name])
.forEach((moduleName) => {
const dirPath = path.resolve(path.join('./node_modules', moduleName));
const packageJson = JSON.parse(fs.readFileSync(path.join(dirPath, 'package.json')));
let repositoryURL = typeof packageJson.repository === 'object' ? packageJson.repository.url : packageJson.repository;
repositoryURL = urlize(repositoryURL);
if (!repositoryURL) return;
const changelogFileName = fs.readdirSync(dirPath).find((name) => name.match(/^CHANGE/i));
if (!changelogFileName) return;
console.log(`${moduleName}: ${repositoryURL}/blob/master/${changelogFileName}`)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment