betterer icon indicating copy to clipboard operation
betterer copied to clipboard

VS Code extension: set betterer working directory

Open Zinggi opened this issue 2 years ago • 3 comments

Hi there :wave: Like https://github.com/phenomnomnominal/betterer/issues/108 I'm trying to run the betterer VS Code extension in a monorepo, but I can't get it to work.

I've set the config path, but it still fails because it can't start betterer:

Validator: Getting Betterer for "/home/.../project_root".
Validator: Betterer isn't installed

It doesn't find betterer, because the project root folder doesn't have a package.json. The package.json and node_modules and hence betterer is not in the project root, they are under ./project_root/sub_folder

Is there a setting to configure the betterer working directory? Or should the config path already do that?

Zinggi avatar Jan 18 '22 13:01 Zinggi

Could you give me a bit more information about your project structure and where you've set the config path too?

phenomnomnominal avatar Apr 11 '22 21:04 phenomnomnominal

Sure. I'm starting VS Code from this folder:

➤ tree -L 2
.
├── app
│   ├── .betterer.cache
│   ├── .betterer.results
│   ├── .betterer.ts
│   ├── node_modules
│   ├── package.json
│   ├── package-lock.json
│   ├── src
│   └── .....
├── README.md
├── server
│   ├ .....

It has no package.json file. Betterer is installed inside the ./app/ folder.

I tried setting the config path to:

  "betterer.configPath": "./app/.betterer.ts",
  "betterer.cachePath": "./app/.betterer.cache",
  "betterer.resultsPath": "./app/.betterer.results"

but that didn't help, I still get [Error - 4:03:07 PM] Validator: Betterer isn't installed

I suspect it tries to do npx betterer in the VSCode working directory, but in my case it would have to do npx betterer inside the ./app folder.

I don't know how other plugins do it without any configuration, but e.g. prettier uses the right executable without any config. Having a config to specify the better command would also be ok.

Zinggi avatar Apr 12 '22 14:04 Zinggi

Had a similar issue and found a workaround: https://github.com/phenomnomnominal/betterer/issues/1034#issuecomment-1441698810

andreialecu avatar Feb 23 '23 12:02 andreialecu