Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created June 29, 2021 20:54
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 isaacs/b588b542b5c99f57129fdaf44f5a386d to your computer and use it in GitHub Desktop.
Save isaacs/b588b542b5c99f57129fdaf44f5a386d to your computer and use it in GitHub Desktop.
const {promisify} = require('util')
const rpj = promisify(require('read-package-json'))
const rpjf = require('read-package-json-fast')
const pj = require.resolve('./package.json')
Promise.all([
rpj(pj),
rpjf(pj),
]).then(console.log)
/*
[
{
name: 'foo',
version: '1.2.3',
directories: { bin: 'bin' },
dependencies: {
'read-package-json': '^3.0.1',
'read-package-json-fast': '^2.0.2'
},
bin: { 'bar.js': 'bin/bar.js', 'foo.js': 'bin/foo.js' },
readme: 'ERROR: No README data found!',
_id: 'foo@1.2.3',
[Symbol(newline)]: '\n',
[Symbol(indent)]: ' '
},
{
name: 'foo',
version: '1.2.3',
directories: { bin: 'bin' },
dependencies: {
'read-package-json': '^3.0.1',
'read-package-json-fast': '^2.0.2'
},
_id: 'foo@1.2.3',
[Symbol(newline)]: '\n',
[Symbol(indent)]: ' '
}
]
*/
@isaacs
Copy link
Author

isaacs commented Jun 29, 2021

$ \tree -I node_modules
.
├── bin
│   ├── bar.js
│   └── foo.js
├── package-lock.json
├── package.json
└── test.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment