Common variables for launch.json in Visual Studio Code

I saw how start.json for Visual Studio Code has access to "$ {workspaceRoot}. Does it also have access to other shared variables? I would like to have access to the user's current appdata folder so that I can:

"program": "${appData}\\Roaming\\npm\\node_modules\\gulp\\bin\\gulp.js"

instead of hard coding:

"program": "C:\\Users\\jdoe\\AppData\\Roaming\\npm\\node_modules\\gulp\\bin\\gulp.js"
+4
source share
1 answer

Variable substitution in launch.json supports environment variables. For your use case you can use ${env.AppData}.

VS Code supports variable substitution within strings in launch.json in the same way as for tasks.json.

https://code.visualstudio.com/docs/editor/tasks#_variable-substitution

  • $ {workspaceRoot} path to the folder opened in VS Code
  • $ {file} current open file
  • ${relativeFile} workspaceRoot
  • ${fileBasename}
  • ${fileDirname} dirname
  • ${_}
  • ${cwd}

${env.Name} (, ${Env.PATH}). , env.Path Windows.

+10

Source: https://habr.com/ru/post/1656604/


All Articles