Define vscode variables - variables

Is there a way to define variables in vscode for use in launch.json?, I only want some variable that will be common to different configurations, let's say TESTING_USER="ABC"
{
"version": "0.2.0",
// it would be ideal to set it here somehow,
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Node",
"runtimeArgs": ["idUser", "${TESTING_USER}"],
},
{
"type": "chrome",
"request": "launch",
"name": "Chrome",
"url": "http://localhost:3000?${TESTING_USER}",
}
],
}
The only solution I've found would be creating an entry in settings.json and then referring it with ${config:xxxx} but I wonder if there's a more direct way.

You can use the extension Command Variable and use a file with key-value pairs
Another possibility is to use the command: extension.commandvariable.transform
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Node",
"runtimeArgs": ["idUser", "${input:TESTING_USER}"],
},
{
"type": "chrome",
"request": "launch",
"name": "Chrome",
"url": "http://localhost:3000?${input:TESTING_USER}",
}
],
"inputs": [
{
"id": "TESTING_USER",
"type": "command",
"command": "extension.commandvariable.transform",
"args": { "text": "ABC" }
}
]
}

Related

VSCODE - How to configure docker compose problem matcher

I've the following workspace configuration
{
"folders": [
{
"path": "."
}
],
"launch": {
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "docker-compose:launch:chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///src/*": "${webRoot}/*"
},
"preLaunchTask": "docker:compose:up",
"postDebugTask": "docker:compose:down"
},
],
},
"tasks": {
"version": "2.0.0",
"tasks": [
{
"label": "npm:install",
"type": "shell",
"command": "npm install",
"linux": {
"command": "if [ -d ${workspaceFolder}/node_modules ]; then npm install fi"
},
"windows": {
"command": "cmd",
"args": ["/C","if not exist ${workspaceFolder}/node_modules npm install"]
},
"options": {"cwd":"${workspaceFolder}"}
},
{
"type": "docker-compose",
"label": "docker:compose:up",
"dependsOn": ["npm:install"],
"isBackground": true,
"dockerCompose": {
"up": {
"detached": true,
"build": true,
"customOptions": "",
"services": [
"site"
]
},
"files": [
"${workspaceFolder}/docker-compose.yaml"
]
}
},
{
"type": "docker-compose",
"label": "docker:compose:down",
"dockerCompose": {
"down": {
"removeVolumes":false
},
"files": [
"${workspaceFolder}/docker-compose.yaml"
]
},
},
]
},
"settings": {
"terminal.integrated.cwd": "${workspaceFolder}"
}
}
The launch("docker-compose:launch:chrome") configuration is not launching the chrome and I think thats happening because it thinks the task is not finished.
As far I know this should be checked using the problemMatcher, for vuejs as an example i can have the following problemMatcher:
"problemMatcher": [{
"base": "$tsc-watch",
"background": {
"activeOnStart": true,
"beginsPattern": "Starting development server",
"endsPattern": "Compiled successfully"
}
}],
How can i achive the same results using docker-compose?
I mean, is there a way to only launch chrome browser when the npm run serve command is finished?

Vue + VSCode unbound breakpoint

I need help with my Vue application.
VSCode says "unbound" breakpoint and it`s not going into the breakpoint, here is my code sample:
<script>
import axios from "#/axios";
export default {
methods: {
async addPreRegisteredUser(email) {
await axios.post("AddPreRegisteredUser", email);
},
},
};
</script>
and here my launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "vuejs: chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src",
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:///src/*": "${webRoot}/*"
}
},
{
"type": "firefox",
"request": "launch",
"name": "vuejs: firefox",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src",
"pathMappings": [{ "url": "webpack:///src/", "path": "${webRoot}/" }]
}
]
}
I set the breakpoints at inside the "addPreRegisteredUser" method, but unfortunately it doesn't jump in.
Do any of you know what the reason is?

Does Anyone Know This Error? React-Native

I am developing React-Native Android application. I get this line when debugging. I wonder why ?
Nobody answers. Two days passed. Help me
React-native Android Debugger Error Code 712 and 303
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to packager",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "attach"
},
{
"command": "npm start",
"name": "Run npm start",
"request": "launch",
"type": "node-terminal"
},
{
"name": "Debug macOS",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "macos"
},
{
"name": "Debug Android",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "android"
},
]
}

Debug React Native app on iPhone with VSCode

I have VSCode installed on Ubuntu with React Native Tools 0.4.1 installed. I can't figure out how to use debug with it. Tried to follow this tutorial with no luck - it just stacks on loading and nothing happens.
My launch.json is created automatically and looks like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Android",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "android",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug iOS",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "ios",
"target": "iPhone 5s",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Attach to packager",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "attach",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug in Exponent",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
}
]
}

Debugging nwjs app in VSCode

I am using VSCode as my primary JS ide and currently working on a NWJS(node-webkit) app. I want use the debugger available in VSCode. Can anyone guide me through how the launchjs should look like.
Can you please try to below lauch.json. it is working for me.
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/camera/app.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
}