Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow for workspace patterns to start with ./ #145

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function appendNegatedPatterns (allPatterns) {
pattern = pattern.slice(excl[0].length)
}

// strip off any / from the start of the pattern. /foo => foo
pattern = pattern.replace(/^\/+/, '')
// strip off any / or ./ from the start of the pattern. /foo => foo
pattern = pattern.replace(/^\.?\/+/, '')

// an odd number of ! means a negated pattern. !!foo ==> foo
const negate = excl && excl[0].length % 2 === 1
Expand Down
6 changes: 6 additions & 0 deletions tap-snapshots/test/test.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ Map {
}
`

exports[`test/test.js TAP workspaces config using relative path globs > should return a valid map 1`] = `
Map {
"a" => "{CWD}/test/tap-testdir-test-workspaces-config-using-relative-path-globs/packages/a",
}
`

exports[`test/test.js TAP workspaces config using simplistic glob > should return a valid map 1`] = `
Map {
"a" => "{CWD}/test/tap-testdir-test-workspaces-config-using-simplistic-glob/packages/a",
Expand Down
28 changes: 28 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,34 @@ test('workspaces config using simplistic glob', t => {
)
})

test('workspaces config using relative path globs', t => {
const cwd = t.testdir({
packages: {
a: {
'package.json': '{ "name": "a" }',
},
b: {
'package.json': '{ "name": "b" }',
},
},
})

return t.resolveMatchSnapshot(
mapWorkspaces({
cwd,
pkg: {
workspaces: {
packages: [
'./packages/*',
'!./packages/b',
],
},
},
}),
'should return a valid map'
)
})

test('duplicated workspaces config', t => {
const cwd = t.testdir({
packages: {
Expand Down