diff --git a/.vscode/launch.json b/.vscode/launch.json index fd47c7c6..3c3e65a5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -83,6 +83,20 @@ "outFiles": ["${workspaceFolder}/out/**/*.js"], "preLaunchTask": "npm: dev", "sourceMapRenames": true + }, + { + "name": "🧩 Debug Extension (yarn pnp)", + "type": "extensionHost", + "request": "launch", + "args": [ + "--disable-extensions", + "--extensionDevelopmentKind=node", + "--extensionDevelopmentPath=${workspaceFolder}", + "${workspaceFolder}/test/fixtures/yarn-pnp" + ], + "outFiles": ["${workspaceFolder}/out/**/*.js"], + "preLaunchTask": "npm: dev", + "sourceMapRenames": true } ] } diff --git a/src/binary-finder.ts b/src/binary-finder.ts index ea68cac5..7c8693e6 100644 --- a/src/binary-finder.ts +++ b/src/binary-finder.ts @@ -194,7 +194,7 @@ const yarnPnpStrategy: LocatorStrategy = { }); for (const extension of ["cjs", "js"]) { - const yarnPnpFile = Uri.file(`${path}/.pnp.${extension}`); + const yarnPnpFile = Uri.joinPath(path, `.pnp.${extension}`); if (!(await fileExists(yarnPnpFile))) { continue; @@ -212,9 +212,11 @@ const yarnPnpStrategy: LocatorStrategy = { continue; } - return yarnPnpApi.resolveRequest( - `${platformSpecificNodePackageName}/${platformSpecificBinaryName}`, - biomePackage, + return Uri.file( + yarnPnpApi.resolveRequest( + `${platformSpecificNodePackageName}/${platformSpecificBinaryName}`, + biomePackage, + ) as string, ); } catch { return undefined; diff --git a/test/fixtures/yarn-pnp/.gitignore b/test/fixtures/yarn-pnp/.gitignore new file mode 100644 index 00000000..870eb6a5 --- /dev/null +++ b/test/fixtures/yarn-pnp/.gitignore @@ -0,0 +1,13 @@ +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions + +# Swap the comments on the following lines if you wish to use zero-installs +# In that case, don't forget to run `yarn config set enableGlobalCache false`! +# Documentation here: https://yarnpkg.com/features/caching#zero-installs + +#!.yarn/cache +.pnp.* diff --git a/test/fixtures/yarn-pnp/README.md b/test/fixtures/yarn-pnp/README.md new file mode 100644 index 00000000..d4f332de --- /dev/null +++ b/test/fixtures/yarn-pnp/README.md @@ -0,0 +1,17 @@ +# Yarn PnP + +This folder contains an example single-root workspace used as a test fixture for +the Biome extension. The workspace folder is setup as a yarn pnp project. + +## Expectations + +When the workspace folder is opened in VS Code, the Biome extension should be active +and used the `biome.json` configuration file at the root of the workspace folder. + +## Test protocol + +1. Open the workspace in VS Code. +2. Run command `yarn` +3. Open the `index.js` file. +4. Run the `Format Document with...` command, and select the Biome extension. +5. Verify that the document gets formatted with `indentWidth` set to `2`. and `indentStyle` set to `space`. \ No newline at end of file diff --git a/test/fixtures/yarn-pnp/biome.json b/test/fixtures/yarn-pnp/biome.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/test/fixtures/yarn-pnp/biome.json @@ -0,0 +1 @@ +{} diff --git a/test/fixtures/yarn-pnp/index.js b/test/fixtures/yarn-pnp/index.js new file mode 100644 index 00000000..54b82a09 --- /dev/null +++ b/test/fixtures/yarn-pnp/index.js @@ -0,0 +1 @@ +const a = 1; diff --git a/test/fixtures/yarn-pnp/package.json b/test/fixtures/yarn-pnp/package.json new file mode 100644 index 00000000..a2b4d8f5 --- /dev/null +++ b/test/fixtures/yarn-pnp/package.json @@ -0,0 +1,8 @@ +{ + "name": "foo", + "version": "0.0.0", + "packageManager": "yarn@4.5.0", + "devDependencies": { + "@biomejs/biome": "1.8.3" + } +} diff --git a/test/fixtures/yarn-pnp/yarn.lock b/test/fixtures/yarn-pnp/yarn.lock new file mode 100644 index 00000000..e69de29b