Sublime Forum

Build file_regex for relative file path in output

#1

I cannot properly configure sublime-build “file_regex” for relative file path in the CLI output.
This is the case when I use npm/yarn script react-scripts start from create-react-app.
For example, the project path is ~/projects/projectOne, and the build output is:

src/subfolder1/model/file1.ts
  Line 66:19:  The object literal notation {} is preferrable  no-new-object

src/subfolder2/pages/subfolder3/file2.tsx
  Line 18:5:  'myConsent' is assigned a value but never used  @typescript-eslint/no-unused-vars
  Line 80:7:  'MyConsent' is assigned a value but never used  @typescript-eslint/no-unused-vars

Double click on src/subfolder1/model/file1.ts does nothing. Probably because
only part of the full file path (~/projects/projectOne/src/subfolder1/model/file1.ts)
is displayed (src/subfolder1/model/file1.ts).

This is a build config I use:

{
  "name": "yarn dev",
  "target": "terminus_exec",
  "cancel": "terminus_cancel_build",
  "shell_cmd": "yarn dev",
  "working_dir": "$project_path",
  "file_regex": "^(\\S+)\\W+Line (\\d+)\\:(\\d+):  ([^\\n]+)",
  "line_regex": "^  Line (\\d+)\\:(\\d+):  ([^\\n]+)"
}

Any hint how to prefix file path with $project_path for double click or F4 in build output?

Thank you, Mario

0 Likes

#2

Relative file names in captured messages are relative to whatever folder the working_dir is set to in the build file. In your case, does that line up with the path that you expect?

0 Likes

#3

Yes.
I do not know does it help - when I navigate build results (F4 and Shift+F4), I see that messages are correctly selected in the build results panel.

0 Likes

#4

Something to check would be to temporarily comment out the target and cancel keys to run it as a regular build and see if it behaves the same way, to narrow down if it’s a Terminus issue or not.

0 Likes

#5

I did it already.
Also, I tried with absolute path for working_dir(with and without ending foreslash :slight_smile: ). No luck.
I tested my regex in regex101.com using Python flavor and looks ok.

0 Likes

#6

Maybe picture tells more :slight_smile:

0 Likes

#7

Does doing this also open the related files?

0 Likes

#8

No. Double-click on message or filename also doesn’t open related file.

0 Likes

#9

I meant using the key bindings to do the navigation; that should be opening files the same as double clicking does, but you mentioned above only that it highlights things in the panel.

For completeness, you should also check if it happens in Safe Mode (if you use ST4).

0 Likes

#10

Right. F4 highlights things in the panel and double-click does nothing.
The same behavior is in Safe Mode. I tried with the build defined in the .sublime-build and in the sublime-project file. No luck with either.

0 Likes