Skip to content

Commit

Permalink
fix: inline/rename/clean up response object
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Jun 22, 2022
1 parent 559a8a0 commit 760dfad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
18 changes: 16 additions & 2 deletions lib/commands/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,29 @@
const { resolve } = require('path')
const Arborist = require('@npmcli/arborist')
const BaseCommand = require('../base-command.js')
const QuerySelectorAllResponse = require('../utils/query-selector-all-response.js')

class QuerySelectorItem {
constructor (node) {
Object.assign(this, node.target.package)

// append extra info
this.pkgid = node.target.pkgid
this.location = node.target.location
this.path = node.target.path
this.realpath = node.target.realpath
this.resolved = node.target.resolved
this.isLink = node.target.isLink
this.isWorkspace = node.target.isWorkspace
}
}

// retrieves a normalized inventory
const convertInventoryItemsToResponses = inventory => {
const responses = []
const responsesSeen = new Set()
for (const node of inventory) {
if (!responsesSeen.has(node.target.realpath)) {
const item = new QuerySelectorAllResponse(node)
const item = new QuerySelectorItem(node)
responses.push(item)
responsesSeen.add(item.path)
}
Expand Down
30 changes: 0 additions & 30 deletions lib/utils/query-selector-all-response.js

This file was deleted.

0 comments on commit 760dfad

Please sign in to comment.