Skip to content

Commit 1b30c72

Browse files
committed
1 parent e57353c commit 1b30c72

File tree

24 files changed

+2282
-3279
lines changed

24 files changed

+2282
-3279
lines changed

lib/workspaces/get-workspaces.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
const { resolve } = require('path')
1+
const { resolve, relative } = require('path')
22
const mapWorkspaces = require('@npmcli/map-workspaces')
33
const minimatch = require('minimatch')
44
const rpj = require('read-package-json-fast')
55

6+
// minimatch wants forward slashes only for glob patterns
7+
const globify = pattern => pattern.split('\\').join('/')
8+
69
// Returns an Map of paths to workspaces indexed by workspace name
710
// { foo => '/path/to/foo' }
811
const getWorkspaces = async (filters, { path, includeWorkspaceRoot, relativeFrom }) => {
@@ -20,9 +23,16 @@ const getWorkspaces = async (filters, { path, includeWorkspaceRoot, relativeFrom
2023

2124
for (const filterArg of filters) {
2225
for (const [workspaceName, workspacePath] of workspaces.entries()) {
26+
let relativePath = relative(relativeFrom, workspacePath)
27+
if (filterArg.startsWith('./')) {
28+
relativePath = `./${relativePath}`
29+
}
30+
const relativeFilter = relative(path, filterArg)
2331
if (filterArg === workspaceName
24-
|| resolve(relativeFrom || path, filterArg) === workspacePath
25-
|| minimatch(workspacePath, `${resolve(relativeFrom || path, filterArg)}/*`)) {
32+
|| resolve(relativeFrom, filterArg) === workspacePath
33+
|| minimatch(relativePath, `${globify(relativeFilter)}/*`)
34+
|| minimatch(relativePath, `${globify(filterArg)}/*`)
35+
) {
2636
res.set(workspaceName, workspacePath)
2737
}
2838
}

node_modules/@npmcli/map-workspaces/node_modules/minimatch/LICENSE

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)