How to run a custom task in Cygwin shell with VSCode? - visual-studio-code

I am trying to set my development environment for an AEM project in VSCode.
I want to create various tasks to automate the syncing, fot that I need to use repo, which only works in the cygwin shell.
The example in the repo documentation for the task definition is the following, but it's thought for mac.
{
"label": "put file",
"type": "shell",
"command": "repo put -f ${file}",
"problemMatcher": []
}
This is what I've been trying, it initializes the cygwin shell but doesn't seem to execute the command and it doesn't finish the task.
{
"label": "put file",
"type": "shell",
"command": "repo put -f ${file}",
"options": {
"shell": {
"executable": "C:\\cygwin64\\bin\\bash.exe",
"args": ["/bin/xhere", "/bin/bash"]
}
},
"problemMatcher": []
}
The output of the console
Can somebody help me? thanks!

I see that you are pushing AEM files to the remote repo and vice versa.
For that you can use other plugins too. As the above answer by Sharath, there are many alternatives.
One is "aemsync". After installing this on your machine, you just have to run the command "aemsync" with or without paramters based on your requirements.
You can install aemsync using nodejs like this:
npm install aemsync -g
You can visit here for a detailed documentation.
https://www.npmjs.com/package/aemsync
There are multiple other ways to push your code, but this is a simple method. Also gulp-slang can be used.
If you want to refer more simplified methods to sync aem, you can refer this.
https://hashouttech.com/simplify-your-aem-coding-with-vault-syncing-between-disk-and-server/

If you are looking to sync front end files to your AEM instance there are other alternatives in the node ecosystem that accomplish this.
You can try gulp-slang, it's a gulp watch task that pushes the changes into AEM as the files change.
and aem-packager to package content

Related

How to open file using vscode tasks in remote vscode

I'd like to be able to use the new vscode tasks feature to open a file in remote vscode. This is useful because I have a bunch of symlinked log files in tmp that I would like to open, and I don't want to type their whole name every time. Ideally it would be something like this:
{
"label": "$(play) open log file",
"type": "shell",
"command": "code /tmp/logfile.INFO",
"group": "build",
},
If I run the same command in the normal vscode terminal, it opens the file correctly. If I run it in the task, the environment doesn't have vscode's bin in the path. If I change code in the task to use the direct path of the remove vscode, it then complains saying "Command is only available in WSL or inside a Visual Studio Code terminal."
I'm unclear if this fails because it is remote vscode or if it fails because it's not possible to open code in a task. Either way it'd be nice to do so :)

How to run Lua script from within VS Code

Have been using Notepad++ for awhile now, and adding scripts via Lua extensions. Now, I would like to get my feet wet using VS Code and was wondering what sort of extensibility I could leverage in that environment? Possible to run the same Lua scripts, for instance? Or are there other avenues I should consider? Thanks for any insights!
Please install the vs-code extensions "LuaDebug" and "extensionPath" provided by actboy168.
Add a file named .vscode/launch.json with the content:
{
"version": "0.2.0",
"configurations": [
{
"type": "lua",
"request": "launch",
"name": "Launch",
"program": "${workspaceFolder}/src/main.lua"
}
]
}
if your source to be executed is src/main.lua.
Then hit F5 or "Run"->"Start Debugging", select the lauch configuration and happy debugging.
An example is also shipped by the author of the plug-in (actboy128), which can be found here: https://github.com/actboy168/luamake
Please do not try to build it, simply load it in VS Code and debug it!
I'm using the following settings to run the interpreter from VSCode using the menu option "Terminal|Run Build Task":
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Run Lua",
"type": "shell",
"command": "lua54",
"args": ["${file}"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
The file contains this settings must be named as "tasks.json". I suggest you to read the VSCode in order to learn how to create it properly.
NOTE: in the command property, where you read "lua54", you must write the name of the lua interpreter executable without the extension.
You would have to configure a task file to run lua from VS code and install lua on your pc if it's isn't done yet.
In order to debug lua you would have to install the extension lua debug which will add a ton of useful feature to help you debug lua such as breakpoint.
Your question seems to touch on several topics:
How to run a Lua script from VS Code: other answers here have already addressed it.
How to extend VS Code: pull up the extension view in VS Code, find an extension you like, and click install. More info here:
https://code.visualstudio.com/docs/editor/extension-marketplace
How to author VS Code extensions: they are written in TypeScript or JavaScript rather than Lua. More info here:
https://code.visualstudio.com/api/get-started/your-first-extension
you can type the following in cmd and it will run the command. Instead of installing extensions.
"C:\Program Files\LOVE\love.exe" "D:\game"
--> this is the path where your main.lua file is

Using Rust Cargo TOML variables within VSCode?

I need to prepare a number of exercises for students learning Rust. I've found the use of ${workspaceFolderBasename} within the program field of my launch.json to be quite useful, as in:
"program": "${workspaceFolder}/target/debug/${workspaceFolderBasename}.exe"
This allows me to execute the program using CTRL+F5. However, this only works while the resulting executable has the same name as the workspace folder (i.e. ${workspaceFolderBasename}). I note that the name field in my project's Cargo.toml file has a name field under [package] which controls the name of the resulting executable. Is there a way to use this field within launch.json?
I want to propose a different approach. What if you define cargo run as a task in your tasks.json with a shortcut and let cargo handle the naming. That also has the advantage that, if students make a change ,cargo will compile it automatically when running cargo run.
This is how to do it:
Create a .vscode folder on project directory.
Create a tasks.json file in it.
In the tasks.json file, my content is like this:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "run",
"type": "shell",
"command": "cargo run",
"problemMatcher": []
}
]
}
Now when you run the command tasks: run task on the command palette, you will see a new task called run. Clicking it will run cargo run on the workspace folder.
The documentation can be found in https://code.visualstudio.com/docs/editor/tasks .
Sidenote: I checked the VsCode Rust Plugin and it seems that they already have that functionality, so just let your students install that extension and they can run all the cargo tasks without doing the above steps.

Is it possible to create a VS Code extension that runs a specific gulp task?

Since I'm a lazy programmer, I've built a gulp task that does some minor tasks for me but I'd like to turn this into an extension so I can install it on my computer and it just "works". Like I install it, boot up VS code and the tasks execute and start watching my code automatically.
I haven't found much things online but then again I could be googling the wrong things. Anything helps - thanks!
Have a look at run task on folderOpen option: vscode docs.
This works for me:
// in tasks.json
{
"label": "Tasks: copy3",
"type": "shell",
"command": "gulp",
"args": [
"copy3",
"--file",
"${fileBasename}"
],
"problemMatcher": [],
"runOptions": {
"runOn": "folderOpen"
}
},
Now the copy3 task in gulpfile.js will automatically be run when that folder (or workspace) is opened. You may have to select Tasks: Allow Automatic Tasks in Folder first in the command palette. And definitely reload.
No extension - it is built-in behaviour more recently. See run task on folder open.
Looks like Yuki Doi had you to it with "Blade Runner". This extension does exactly what you're looking for, it automatically runs build task when a folder is opened.
Related question

Can VSCode (Visual Studio Code) be used to run elm-make?

I am new to VSCode.
I am new to ELM.
I am perfectly capable of using VIM and command line tools to create an ELM Project, but I want to utilize an IDE. I have chosen VSCode on advice from the internet since it seems to pick up some nice pieces of VIM.
So now I have a few .elm files.
Main.elm
View.elm
Model.elm
I want to run elm-make on Model.elm to make sure it has no errors.
Then I want to run elm-make on Main.elm to create an index.html so I can view my project.
I think this is a pretty simple question for people familiar with how to customize VSCode, but as I stated previously, I am new to VSCode.
Try setting up a task for elm-make:
Create a ./vscode/tasks.json with the contents:
{
"version": "0.1.0",
"tasks": [
{
"taskName": "elm make",
"isBuildCommand": true,
"command": "elm-make",
"args": ["./main.elm"],
"isShellCommand": true
}
]
}
You can then use the build command to run the task, or run the task individually.
You may also want to look into the elm extension: https://marketplace.visualstudio.com/items?itemName=sbrink.elm