rioj7 / command-variable

Visual Studio Code extension for variable substitution via ${command:commandID}
51 stars 10 forks source link

Cannot read properties `fsPath` #67

Closed jeffmilanes closed 1 year ago

jeffmilanes commented 1 year ago

Hi @rioj7

I got an error when using this updated package.

Screenshot 2023-06-30 at 10 57 07 AM

Previously it was working then after an update i got this error. Here's my implementation on launch.json

Screenshot 2023-06-30 at 11 07 04 AM

rioj7 commented 1 year ago

@jeffmilanes

It is always best to not include pictures of text. I have to type it over and I'm not allowed to make a mistake. And I think it is easier just copy/paste between triple backtick lines.

 ```json
 "inputs": [
   {

   }
 ]
 ```

results in

"inputs": [
  {

  }
]

It is not the reason but why do you have "display": "fileName" a property of the pickFile property? It will never be used. If you want it you have to set it as a property of the config property.

I will recreate your setup and try to replicate the error and find the reason.

jeffmilanes commented 1 year ago

@rioj7 My bad, i'm debugging it actually, here's the text version.

"inputs": [
        {
            "id": "appEnvironment",
            "type": "command",
            "command": "extension.commandvariable.file.content",
            "args": {
                "fileName": "${pickFile:config}",
                "json": "content.appEnvironment",
                "pickFile": {
                    "config": {
                        "description": "Select the environment to debug",
                        "include": ".secrets/*.json",
                        "keyRemember": "secretsFile"
                    }
                }
            }
        }
    ],
rioj7 commented 1 year ago

@jeffmilanes

I have looked at the code and I missed a case, I never tested it without fromFolder or fromWorkspace, I will add some unit tests to prevent this from happening.

As a workaround, I will change it to use this as default, set the folder to use to the "${workspaceFolder}" variable:

"inputs": [
        {
            "id": "appEnvironment",
            "type": "command",
            "command": "extension.commandvariable.file.content",
            "args": {
                "fileName": "${pickFile:config}",
                "json": "content.appEnvironment",
                "pickFile": {
                    "config": {
                        "description": "Select the environment to debug",
                        "include": ".secrets/*.json",
                        "keyRemember": "secretsFile",
                        "fromFolder": {
                          "fixed": "${workspaceFolder}"
                        }
                    }
                }
            }
        }
    ],

I will update the README too because the text there is misleading.

rioj7 commented 1 year ago

@jeffmilanes can you try v1.54.1 without the "fromFolder" property (just rename it to "XXfromFolder" to try)

jeffmilanes commented 1 year ago

@rioj7 it's working now without fromFolder