Browse Source

Rework powershell script to update all the files from templates with .orig suffix.

master
Aaron Hicks 7 years ago
parent
commit
34c53b4d85
4 changed files with 28 additions and 8 deletions
  1. 0
    0
      manifests/init.pp.orig
  2. 0
    8
      setauthor.ps1
  3. 0
    0
      tests/init.pp.orig
  4. 28
    0
      unblank.ps1

manifests/init.pp → manifests/init.pp.orig View File


+ 0
- 8
setauthor.ps1 View File

@@ -1,8 +0,0 @@
Param($author)
if ($author -match "^\w+$") {
echo "Replacing author with $author..."
Get-Content Modulefile.orig | Foreach-Object {$_ -replace "aethylred", $author} | Set-Content Modulefile
echo "New Modulefile created"
} else {
echo "Bad author '$author', must be a single word made up of word caracters [a-zA-Z_0-9]"
}

tests/init.pp → tests/init.pp.orig View File


+ 28
- 0
unblank.ps1 View File

@@ -0,0 +1,28 @@
Param($author,$module)
if ($author -match "^\w+$") {
if ($module -match "^\w+$") {
echo "Update Modulefile..."
$modulefile = Get-Content Modulefile.orig
$modulefile = Foreach-Object {$modulefile -replace "aethylred", $author}
$modulefile = Foreach-Object {$modulefile -replace "blank", $module}
Set-Content Modulefile $modulefile
echo "Modulefile updated."

echo "Update manifests/init.pp..."
$initfile = Get-Content manifests/init.pp.orig
$initfile = Foreach-Object {$initfile -replace "blank", $module}
Set-Content manifests/init.pp $initfile
echo "manifests/init.pp updated."

echo "Update tests\init.pp..."
$testfile = Get-Content tests/init.pp.orig
$testfile = Foreach-Object {$testfile -replace "blank", $module}
Set-Content tests/init.pp $testfile
echo "tests/init.pp updated."

} else {
throw "ERROR: Bad module parameter '$module', must be a single word made up of word caracters [a-zA-Z_0-9]"
}
} else {
throw "ERROR: Bad author parameter '$author', must be a single word made up of word caracters [a-zA-Z_0-9]"
}

Loading…
Cancel
Save