From c64ee6ff4cdfe20c4a79348ddcbd2396b82ff88c Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 4 Feb 2021 00:28:22 -0500 Subject: [PATCH] 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`). --- src/static/js/pluginfw/read-installed.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/static/js/pluginfw/read-installed.js b/src/static/js/pluginfw/read-installed.js index b035cb0a..e679f030 100644 --- a/src/static/js/pluginfw/read-installed.js +++ b/src/static/js/pluginfw/read-installed.js @@ -303,11 +303,14 @@ if (module === require.main) { console.error('testing'); let called = 0; - 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)); + 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 = [];