Created
May 14, 2018 21:17
-
-
Save gabemeola/f13c9553bb1cf2e23e5a6e8b87e5db40 to your computer and use it in GitHub Desktop.
Grab all external dependencies from package.json
This file contains hidden or 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
/** | |
* Usage: | |
* import package from './package.json' | |
* | |
* externals(package) | |
*/ | |
function externals(pkg) { | |
return Object.keys(pkg).reduce((accumulator, key) => { | |
if (key.match(/dependencies/i)) { | |
const value = pkg[key]; | |
return accumulator.concat(Object.keys(value)); | |
} | |
return accumulator; | |
}, []); | |
} | |
exports default externals |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment