Skip to content

Commit

Permalink
deps: minimatch@5.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Apr 6, 2022
1 parent 7eaf32f commit 6bcf5c1
Show file tree
Hide file tree
Showing 23 changed files with 2,187 additions and 3,198 deletions.
23 changes: 15 additions & 8 deletions lib/workspaces/get-workspaces.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
const { resolve } = require('path')
const path = require('path')
const mapWorkspaces = require('@npmcli/map-workspaces')
const minimatch = require('minimatch')
const rpj = require('read-package-json-fast')

// Returns an Map of paths to workspaces indexed by workspace name
// { foo => '/path/to/foo' }
const getWorkspaces = async (filters, { path, includeWorkspaceRoot, relativeFrom }) => {
const getWorkspaces = async (filters, { path: filePath, includeWorkspaceRoot, relativeFrom }) => {
// TODO we need a better error to be bubbled up here if this rpj call fails
const pkg = await rpj(resolve(path, 'package.json'))
const workspaces = await mapWorkspaces({ cwd: path, pkg })
const pkg = await rpj(path.resolve(filePath, 'package.json'))
const workspaces = await mapWorkspaces({ cwd: filePath, pkg })
let res = new Map()
if (includeWorkspaceRoot) {
res.set(pkg.name, path)
res.set(pkg.name, filePath)
}

if (!filters.length) {
Expand All @@ -20,9 +20,16 @@ const getWorkspaces = async (filters, { path, includeWorkspaceRoot, relativeFrom

for (const filterArg of filters) {
for (const [workspaceName, workspacePath] of workspaces.entries()) {
if (filterArg === workspaceName
|| resolve(relativeFrom || path, filterArg) === workspacePath
|| minimatch(workspacePath, `${resolve(relativeFrom || path, filterArg)}/*`)) {
if (
filterArg === workspaceName
|| path.resolve(relativeFrom || filePath, filterArg) === workspacePath
// path.posix is used here because minimatch wants forward slashes only
// for glob patterns
|| minimatch(
workspacePath,
`${path.posix.resolve(relativeFrom || filePath, filterArg)}/*`
)
) {
res.set(workspaceName, workspacePath)
}
}
Expand Down
15 changes: 0 additions & 15 deletions node_modules/@npmcli/map-workspaces/node_modules/minimatch/LICENSE

This file was deleted.

Loading

0 comments on commit 6bcf5c1

Please sign in to comment.