I am trying to build an extension for vscode for a specific file format.
Now I want to run a custom build script (a batch file that is placed inside the custom extension) that gets exectued when the user presses ctrl+shift+B
I successfully created such a behaviour in a sublime3 extension where the sublime-build script looks like that:
{
"working_dir": "${project_path:${folder:${file_path}}}",
"shell": true,
"osx":
{
"cmd": ["cd '$packages/myextension/buildscript/' && ./mybuildscript.sh $file"]
},
"windows":
{
"shell_cmd": "cd '$packages/myextension/buildscript/' && ./mybuildscript.bat $file",
},
"linux":
{
"cmd": ["cd '$packages/myextension/buildscript/' && ./mybuildscript.sh $file"]
}
}
Can you provide an example how something similar can be done in the vscode extension?
Related
According to the documentation the following should do it:
app.on("open-file", (event, path) => {
event.preventDefault();
console.log("OPEN FILE???");
});
The console log is never called. I have tried:
Choosing "open with" and the application by right clicking on a file.
Use open with while the app is open.
Dragging a file on the dock icon.
It might be quite significant how I build it too. I use electron-builder and have this in my package.json:
"build": {
"appId": "com.myname.someid",
"mac": {
"fileAssociations": [
{
"ext": [
"mp3"
]
}
]
}
}
Then I run electron-builder after installing it.
I have retested it in electron-quick-start and after following the above steps it still fails.
According to this tutorial this is also how you should do it:
https://roysegall.medium.com/electron-open-with-for-mac-osx-f215a1fe2ce1
I have a task created that runs some unittests via bash_unit.
The bash unit script seems to fail based on its use of which.
If I replace:
CAT="$(which cat)"
and other which referances in bash unit to point to my local commands all runs great.
If I run bash)unit directly all good, but if i run it as a vscode task it fails.
I have simplified the task below to the minimum failure:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "run which",
"type": "shell",
"command": "/usr/bin/which which",
"problemMatcher": [],
"group": "test",
}
]
}
This produces the following:
The terminal process "/bin/bash '-c', '/usr/bin/which which'" failed to launch (exit code: 1).
Any ideas what is happening?
I'm trying to write a task to create a directory using Visual studio Code tasks (in tasks.json) for windows users using the mkdir command, it's working well except when the folder already exists.
tasks.json
{
"label": "(release) create build directory",
"type": "shell",
"linux": {
"command": "mkdir -p ./build/release"
},
"windows": {
"command": "mkdir .\\build\\release", // Not working when folder already exists !
}
},
What I tried:
"command": "IF NOT EXIST .\\build\\release mkdir .\\build\\release"
But then I get the error:
At line:1 char:3
+ IF NOT EXIST .\build\release mkdir .\build\release
+ ~
Missing '(' after 'IF' in if statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingOpenParenthesisInIfStatement
If it is not possible to do it this way, is it possible to run this task by ignoring the exit code ? ( so that the tasks continue to build my project)
Environment:
Visual Studio code 1.40.2
Windows 10 Pro x64
I found a way of doing it by using cmd.exe with /C option (Run Command and then terminate)
{
"label": "(release) create build directory",
"type": "shell",
"linux": {
"command": "mkdir -p ./build/release"
},
"windows": {
"command": "cmd",
"args": ["/C", "if not exist .\\build\\release mkdir .\\build\\release"]
}
},
I am struggling with getting my Visual Studios code task to work. The problem is that it seems like the task/.bat file is not being executed.
VS Code task configuration:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "My Label",
"type": "shell",
"windows": {
"command": "'c:\\Program Files (x86)\\path\\to\\the\\file.bat${file}'"
},
"presentation": {
"reveal": "always"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
For testing purposes the file.bat contains:
echo "------"
echo %1
echo "------"
The output in Visual Studio Code terminal is:
> Executing task in folder User: 'c:\\Program Files (x86)\\path\\to\\the\\file.bat c:\project\file.abc' <
c:\\Program Files (x86)\\path\\to\\the\\file.bat c:\project\file.abc
Terminal will be reused by tasks, press any key to close it.
I expected that the ${file} argument/value to printed in the console. The problem is that nothing is printed. It doesn't matter if I intentionally make syntax errors in the bat file. From VS Code it seems like the .bat file is not executed at all.
The shell being used is PowerShell
Configuration:
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
Thank you in advance!
T
You just have a slight syntax error using double quotes and single quotes together.
Change to:
...
"windows": {
"command": "c:\\Program Files (x86)\\path\\to\\the\\file.bat ${file}"
}
...
New to Sublime,here's my current build system:
{
"windows":
{
"cmd": ["g++", "$file_name","-o", "${file_base_name}.exe", "-lm", "-Wall","&","start", "${file_base_name}.exe"]
},
"selector": "source.c++",
"shell": true,
"working_dir": "${file_path}"
}
It would be nice to edit the build system so that the cmd window would not close after finishing the program.(Idealy same as system ("pause") at the end of the program or pause in .bat files)
Use the following setting:
Menu > Preferences > Settings
// Shows the Build Results panel when building. If set to false, the Build
// Results can be shown via the Tools/Build Results menu.
"show_panel_on_build": true,