I want to use TypeScript as a scripting language for my machine and so I want to be able just to execute TypeScript files directly. There are npm packages like ts-node that do this already but I wanted to have a crack at implementing it myself. So this is the batch file I've come up with so far.Read More
Sometimes it's helpful to exit out of a batch script if there are pending changes to a repo. This is done in batch script in a non intuitive way.
@ECHO OFF PUSHD %~dp0 SET __HAS_CHANGES=0 REM The loop won't be executed if 'git status -s' doesn't produce any output. FOR /f "tokens=*" %%i IN ('git status -s') DO ( SET __HAS_CHANGES=1 ) REM Check if the loop was executed and goto EXIT if it was. IF "%__HAS_CHANGES%" NEQ "0" ( ECHO There are currently uncommitted changes. GOTO EXIT ) REM Do the work you want to do here. :EXIT POPD
Here's a quick one liner to quickly stage all your changes in the current git repo, commit them and then push the commit to origin master branch.Read More