pluginfw: Call `npm.load()` before using `npm`

This code is only used when testing `read-installed.js` by running it
directly (e.g., `node src/static/js/pluginfw/read-installed.js`).
pull/4675/head^2
Richard Hansen 2021-02-04 00:28:22 -05:00 committed by John McLear
parent a5bde7982a
commit c64ee6ff4c
1 changed files with 8 additions and 5 deletions

View File

@ -303,12 +303,15 @@ if (module === require.main) {
console.error('testing');
let called = 0;
npm.load({}, (err) => {
if (err != null) throw err;
readInstalled(process.cwd(), (er, map) => {
console.error(called++);
if (er) return console.error(er.stack || er.message);
cleanup(map);
console.error(util.inspect(map, true, 10, true));
});
});
const seen = [];
function cleanup(map) {