Update make version to check for git.
This will prevent the version from being set to null if git isn't in the path.
This commit is contained in:
35
make.ps1
35
make.ps1
@@ -30,7 +30,7 @@ if ($args.Length -eq 0)
|
|||||||
echo " 'dependencies' commands to restore removed files."
|
echo " 'dependencies' commands to restore removed files."
|
||||||
echo " test Tests the default mods for errors."
|
echo " test Tests the default mods for errors."
|
||||||
echo ""
|
echo ""
|
||||||
$command = Read-Host "Enter command"
|
$command = (Read-Host "Enter command").Split(' ', 2)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -74,19 +74,34 @@ elseif ($command -eq "clean")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($command -eq "version")
|
elseif ($command -eq "version")
|
||||||
{
|
{
|
||||||
$version = git name-rev --name-only --tags --no-undefined HEAD 2>$null
|
if ($command.Length -gt 1)
|
||||||
if ($version -eq $null)
|
|
||||||
{
|
{
|
||||||
$version = "git-" + (git rev-parse --short HEAD)
|
$version = $command[1]
|
||||||
}
|
}
|
||||||
$mods = @("mods/ra/mod.yaml", "mods/cnc/mod.yaml", "mods/d2k/mod.yaml", "mods/modchooser/mod.yaml")
|
elseif (Get-Command 'git' -ErrorAction SilentlyContinue)
|
||||||
foreach ($mod in $mods)
|
|
||||||
{
|
{
|
||||||
$replacement = (gc $mod) -Replace "Version:.*", ("Version: {0}" -f $version)
|
$version = git name-rev --name-only --tags --no-undefined HEAD 2>$null
|
||||||
sc $mod $replacement
|
if ($version -eq $null)
|
||||||
|
{
|
||||||
|
$version = "git-" + (git rev-parse --short HEAD)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "Unable to locate Git. The version will remain unchanged."
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($version -ne $null)
|
||||||
|
{
|
||||||
|
$mods = @("mods/ra/mod.yaml", "mods/cnc/mod.yaml", "mods/d2k/mod.yaml", "mods/modchooser/mod.yaml")
|
||||||
|
foreach ($mod in $mods)
|
||||||
|
{
|
||||||
|
$replacement = (gc $mod) -Replace "Version:.*", ("Version: {0}" -f $version)
|
||||||
|
sc $mod $replacement
|
||||||
|
}
|
||||||
|
echo ("Version strings set to '{0}'." -f $version)
|
||||||
}
|
}
|
||||||
echo ("Version strings set to '{0}'." -f $version)
|
|
||||||
}
|
}
|
||||||
elseif ($command -eq "dependencies")
|
elseif ($command -eq "dependencies")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user