Skip to content

Commit 0ec863e

Browse files
authored
fix: ensure isPrivateWorkspacePackage works on windows (#26)
1 parent 971d4e1 commit 0ec863e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,10 @@ async function readJson(findDepPkgJsonPath) {
306306
* @returns {boolean}
307307
*/
308308
function isPrivateWorkspacePackage(pkgJsonPath,pkgJson,workspaceRoot = undefined) {
309-
return !!workspaceRoot
310-
&& pkgJson.private
311-
&& pkgJsonPath.startsWith(workspaceRoot)
312-
&& !pkgJsonPath.match(/[/\\]node_modules[/\\]/)
309+
return !!(
310+
workspaceRoot &&
311+
pkgJson.private &&
312+
!pkgJsonPath.match(/[/\\]node_modules[/\\]/) &&
313+
!path.relative(workspaceRoot,pkgJsonPath).startsWith('..')
314+
)
313315
}

tests/projects/workspace/workspace.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { test } from 'uvu'
33
import * as assert from 'uvu/assert'
44
import {crawlFrameworkPkgs} from '../../../src/index.js'
55

6-
const workspaceRoot = fileURLToPath(new URL('../../../', import.meta.url)).replace(/\/$/,'')
6+
const workspaceRoot = fileURLToPath(new URL('../../../', import.meta.url))
7+
.replace(/\\/g,'/') // vite's seachForWorkspaceRoot returns slashified string on windows do that here too
8+
.replace(/\/$/,'')
79
const root = fileURLToPath(new URL('./packages/workspace-app', import.meta.url)).replace(/\/$/,'')
810

911
test('crawlFrameworkPkgs (dev)', async () => {

0 commit comments

Comments
 (0)