diff --git a/lib/walker.js b/lib/walker.js index 2b91d41e8..ae079bfa6 100644 --- a/lib/walker.js +++ b/lib/walker.js @@ -309,7 +309,7 @@ class Walker { try { detector.detect(body, (node, trying) => { - const { hasDictionary } = record.marker; + const { toplevel } = record.marker; let d = detector.visitor_SUCCESSFUL(node); if (d) { if (d.mustExclude) return false; @@ -320,7 +320,7 @@ class Walker { d = detector.visitor_NONLITERAL(node); if (d) { if (d.mustExclude) return false; - const debug = hasDictionary || d.mayExclude || trying; + const debug = !toplevel || d.mayExclude || trying; const level = debug ? 'debug' : 'warn'; log[level](`Cannot resolve '${d.alias}'`, [ record.file, 'Dynamic require may fail at run time, because the requested file', @@ -332,7 +332,7 @@ class Walker { d = detector.visitor_MALFORMED(node); if (d) { // there is no 'mustExclude' - const debug = hasDictionary || trying; + const debug = !toplevel || trying; const level = debug ? 'debug' : 'warn'; // there is no 'mayExclude' log[level](`Malformed requirement for '${d.alias}'`, [ record.file ]); return false; diff --git a/test/test-50-should-disclose-package/main.js b/test/test-50-should-disclose-package/main.js index 4399cb54a..364e47744 100644 --- a/test/test-50-should-disclose-package/main.js +++ b/test/test-50-should-disclose-package/main.js @@ -17,8 +17,7 @@ const standard = 'stdout'; function rightReducer (mappy, line, index, right) { if ((line.indexOf('Cannot resolve') >= 0) || (line.indexOf('The file was included') >= 0)) { - let name = path.basename(right[index + 1]); - if (right[index].indexOf(' Warning ') >= 0) name += ' (w)'; + const name = path.basename(right[index + 1]); let value = right[index].split(' as ')[1] || ''; value = value || right[index].split(' Warning ')[1]; if (mappy[name]) assert.equal(mappy[name], value); @@ -53,11 +52,8 @@ for (const pub of [ false, true ]) { assert.equal(lines, 'connect.js = DISCLOSED code (with sources)\n' + 'has-no-license.js = bytecode (no sources)\n' + - 'has-no-license.js (w) = Cannot resolve \'hasNoLicenseNonLiteral\'\n' + 'has-permissive-license.js = DISCLOSED code (with sources)\n' + - 'has-permissive-license.js (w) = Cannot resolve \'hasPermissiveLicenseNonLiteral\'\n' + 'has-strict-license.js = bytecode (no sources)\n' + - 'has-strict-license.js (w) = Cannot resolve \'hasStrictLicenseNonLiteral\'\n' + 'package.json = DISCLOSED code (with sources)\n' + (pub ? 'test-x-index.js = DISCLOSED code (with sources)\n' : 'test-x-index.js = bytecode (no sources)\n')