Created
August 4, 2018 06:55
-
-
Save SgtPooki/b4e1d46d624ee0a0d0260d0819ae03c5 to your computer and use it in GitHub Desktop.
Find names and versions of root modules and typings in your project.
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 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