Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/lib/audit-report.js b/lib/audit-report.js
index 77cd6511..e585d827 100644
--- a/lib/audit-report.js
+++ b/lib/audit-report.js
@@ -101,6 +101,7 @@ class AuditReport extends Map {
async run () {
this.report = await this[_getReport]()
+ this.log.silly('audit report', this.report)
if (this.report)
await this[_init]()
return this
@@ -289,6 +290,7 @@ class AuditReport extends Map {
try {
// first try the super fast bulk advisory listing
const body = prepareBulkData(this.tree, this[_omit])
+ this.log.silly('audit', 'bulk request', body)
// no sense asking if we don't have anything to audit,
// we know it'll be empty
@@ -304,7 +306,8 @@ class AuditReport extends Map {
})
return await res.json()
- } catch (_) {
+ } catch (er) {
+ this.log.silly('audit', 'bulk request failed', String(er.body))
// that failed, try the quick audit endpoint
const body = prepareData(this.tree, this.options)
const res = await fetch('/-/npm/v1/security/audits/quick', {
diff --git a/lib/node.js b/lib/node.js
index a54f76af..cdda25ef 100644
--- a/lib/node.js
+++ b/lib/node.js
@@ -111,10 +111,21 @@ class Node {
const pkg = sourceReference ? sourceReference.package
: normalize(options.pkg || {})
- this.name = name ||
- nameFromFolder(path || pkg.name || realpath) ||
- pkg.name ||
- null
+ if (name)
+ this.name = name
+ else {
+ const { name: pkgname } = pkg
+ const nff = nameFromFolder(path)
+ const nm = !nff ? false
+ : nff.includes('/') ? basename(dirname(dirname(path)))
+ : basename(dirname(path))
+ if (nm === 'node_modules')
+ this.name = nff
+ else if (pkg.name)
+ this.name = pkg.name
+ else
+ this.name = null
+ }
// should be equal if not a link
this.path = path ? resolve(path) : null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment