I'm trying to create a snippet that creates a class name based on the file path. If the file is named index.js, I'd like the class name to take the folder name. Otherwise, use the file name.
I've got a transform (shown below) that is currently working if the file is named index.js (it correctly inserts the folder name).
How would I expand on this (assuming it's even possible) to also work for the second case?
I did notice from the VSCode documentation that there are some basic if/else formats that you can use, which will only insert the given text if a capture group exists. I have been able to get those working with some simple examples. But not sure if these can be used in some way to accomplish what I'm trying to do.
Current snippet:
{
"mySnippet": {
"prefix": "cls",
"body": [
"class ${TM_FILEPATH/[\\/\\w$]+\\/(?!index)|\\/index.js//g} {}",
"export default ${TM_FILEPATH/[\\/\\w$]+\\/(?!index)|\\/index.js//g};"
]
},
}
