Skip to content

Instantly share code, notes, and snippets.

@gabemeola
Created May 14, 2018 21:17
Show Gist options
  • Save gabemeola/f13c9553bb1cf2e23e5a6e8b87e5db40 to your computer and use it in GitHub Desktop.
Save gabemeola/f13c9553bb1cf2e23e5a6e8b87e5db40 to your computer and use it in GitHub Desktop.
Grab all external dependencies from package.json
/**
* 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