Skip to content

Instantly share code, notes, and snippets.

@EmilienLeroy
Last active November 8, 2020 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EmilienLeroy/6290617400732139a948e25004d263bc to your computer and use it in GitHub Desktop.
Save EmilienLeroy/6290617400732139a948e25004d263bc to your computer and use it in GitHub Desktop.
Script Manager (Windows)
@ECHO OFF
rem simple script for c++ project.
rem run dev
rem compile the project, run it and delete it after execution.
IF "%1"=="dev" g++ main.cpp -o app & app.exe & del app.exe & goto exit
rem run build
rem compile prodution exe.
IF "%1"=="build" g++ main.cpp -o app & goto exit
:exit
# This script will execute command from 'script.json' file
# ./run.ps1 dev
# see the script.json
param([string] $cmd);
$script = (Get-Content 'script.json' | Out-String | ConvertFrom-Json);
$execs = $script."$cmd" -split "&";
Foreach($exec in $execs)
{
try {
Invoke-Expression -Command $exec;
} catch {
Write-Host "An error occurred."
}
}
{
"dev": "g++ main.cpp -o app & ./app.exe & del ./app.exe",
"build": "g++ main.cpp -o app"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment