Skip to content

Instantly share code, notes, and snippets.

@SgtPooki
Created August 4, 2018 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SgtPooki/b4e1d46d624ee0a0d0260d0819ae03c5 to your computer and use it in GitHub Desktop.
Save SgtPooki/b4e1d46d624ee0a0d0260d0819ae03c5 to your computer and use it in GitHub Desktop.
Find names and versions of root modules and typings in your project.
const glob = require('glob');
const globPromise = (string) => new Promise((resolve, reject) => {
glob(string, (error, result) => {
if (error) {
reject(error);
}
resolve(result);
});
});
const getNamesAndVersions = (file) => {
const json = require(`./${file}`);
return `${json.name}@${json.version}`;
};
const modules = globPromise('./node_modules/*/package.json');
const types = globPromise('./node_modules/@types/*/package.json');
Promise.all([modules, types]).then((a) => {
const versions = [...a[0], ...a[1]].map(getNamesAndVersions);
console.log(versions.join('\n'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment