Skip to content

Commit ed4a063

Browse files
author
Iwan
committed
Tweak heuristics to find the project root.
The project root means "this is a folder containing node_modules/bs-platform/{platform}/bsc.exe". This path needs to be correct because it drives the formatter. The previous heuristics seemed to fail in the case users where using yarn workspaces. Yarn workspaces seem to have the following layout: ``` /root /node_modules - package.json - yarn.lock /folder1 /node_modules - package.json - bsconfig.json ``` The compiler seems to be located in the `node_modules` under the root and not in the `node_modules` of `folder1`. By searching for `bscPartialPath` instead of the nearest `bsconfig.json`, we can correctly determine the root.
1 parent 63b37a0 commit ed4a063

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

server/src/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ process.on("message", (msg: m.Message) => {
375375
if (projectRootPath == null) {
376376
let params: p.ShowMessageParams = {
377377
type: p.MessageType.Error,
378-
message: `Cannot find a nearby ${c.bsconfigPartialPath}. It's needed for determining the project's root.`,
378+
message: `Cannot find a nearby ${c.bscPartialPath}. It's needed for determining the project's root.`,
379379
};
380380
let response: m.NotificationMessage = {
381381
jsonrpc: c.jsonrpcVersion,

server/src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export let findProjectRootOfFile = (
1313
source: p.DocumentUri
1414
): null | p.DocumentUri => {
1515
let dir = path.dirname(source);
16-
if (fs.existsSync(path.join(dir, c.bsconfigPartialPath))) {
16+
if (fs.existsSync(path.join(dir, c.bscPartialPath))) {
1717
return dir;
1818
} else {
1919
if (dir === source) {

0 commit comments

Comments
 (0)