Skip to content

Commit c04b704

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 b0a5c83 commit c04b704

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
@@ -419,7 +419,7 @@ process.on("message", (msg: m.Message) => {
419419
if (projectRootPath == null) {
420420
let params: p.ShowMessageParams = {
421421
type: p.MessageType.Error,
422-
message: `Cannot find a nearby ${c.bsconfigPartialPath}. It's needed for determining the project's root.`,
422+
message: `Cannot find a nearby ${c.bscPartialPath}. It's needed for determining the project's root.`,
423423
};
424424
let response: m.NotificationMessage = {
425425
jsonrpc: c.jsonrpcVersion,

server/src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export let findProjectRootOfFile = (
2222
source: p.DocumentUri
2323
): null | p.DocumentUri => {
2424
let dir = path.dirname(source);
25-
if (fs.existsSync(path.join(dir, c.bsconfigPartialPath))) {
25+
if (fs.existsSync(path.join(dir, c.bscPartialPath))) {
2626
return dir;
2727
} else {
2828
if (dir === source) {

0 commit comments

Comments
 (0)