Skip to content

Commit 7844478

Browse files
committed
feat: basic debug/progress logging
1 parent 1de296c commit 7844478

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/deps.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

3+
const Debug = require('debug');
34
const { Arborist } = require('@npmcli/arborist');
45
const Fs = require('fs');
56
const Path = require('path');
@@ -11,6 +12,9 @@ const Utils = require('./utils');
1112
const internals = {};
1213

1314

15+
internals.log = Debug('detect-node-support');
16+
17+
1418
internals.walk = (node, callback) => {
1519

1620
callback(node);
@@ -103,14 +107,22 @@ internals.tryLoad = async (loadFile, filename) => {
103107
exports.detect = async ({ packageJson, loadFile }, options) => {
104108

105109
const lockfile = (await internals.tryLoad(loadFile, 'package-lock.json')) || (await internals.tryLoad(loadFile, 'npm-shrinkwrap.json'));
110+
internals.log(lockfile ? 'Lock file present' : 'Lock file missing - things will be a bit slower');
106111

107112
const versions = await internals.resolve({ packageJson, lockfile }, options);
108113

109114
const support = [];
110115
const errors = {};
111116
let hasErrors = false;
112117

113-
for (const packageName of Object.keys(versions).sort()) {
118+
const packages = Object.keys(versions).sort();
119+
const n = packages.length;
120+
121+
for (let i = 0; i < n; ++i) {
122+
123+
const packageName = packages[i];
124+
internals.log(`Resolving dependency ${i + 1} of ${n}: ${packageName}`);
125+
114126
try {
115127
const { result } = await Package.detect({ packageName });
116128
support.push(result);

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@hapi/wreck": "^17.0.0",
3939
"@npmcli/arborist": "0.0.0-pre.14",
4040
"@pkgjs/nv": "0.0.3",
41+
"debug": "^4.1.1",
4142
"git-url-parse": "^11.1.2",
4243
"js-yaml": "^3.13.1",
4344
"minimist": "^1.2.5",

0 commit comments

Comments
 (0)