node/deps/npm/node_modules/@npmcli/arborist/lib/debug.js
Luigi Pinca dc05c70c8f
deps: upgrade npm to 7.0.7
PR-URL: https://github.com/nodejs/node/pull/35908
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Ruy Adorno <ruyadorno@github.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
2020-11-02 16:18:50 -05:00

19 lines
669 B
JavaScript

// certain assertions we should do only when testing arborist itself, because
// they are too expensive or aggressive and would break user programs if we
// miss a situation where they are actually valid.
//
// call like this:
//
// /* istanbul ignore next - debug check */
// debug(() => {
// if (someExpensiveCheck)
// throw new Error('expensive check should have returned false')
// })
const debug = process.env.ARBORIST_DEBUG === '1' ||
/\barborist\b/.test(process.env.NODE_DEBUG || '') ||
process.env.npm_package_name === '@npmcli/arborist' &&
['test', 'snap'].includes(process.env.npm_lifecycle_event)
module.exports = debug ? fn => fn() : () => {}