Created
September 11, 2022 10:31
-
-
Save BroVic/30bdb14c66e5da9b9ce36d1d552594a3 to your computer and use it in GitHub Desktop.
A PowerShell script for automating R CMD ... for the naijR package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source file: rcmd.ps1 | |
# | |
# A PowerShell script for batch execution of R specifically | |
# for the naijR project | |
# TODO: Affirm script execution policy | |
[CmdletBinding()] | |
PARAM ( | |
[ValidateSet('build', 'check')] | |
[string]$Command = "build", | |
[string]$pkgname = "naijR", | |
[string]$opts = $null | |
) | |
if ($Command.Equals("build")) { | |
$opts = "--resave-data" | |
} | |
elseif ($Command.Equals("check")) { | |
# TODO: Add a check for new unbuilt version of | |
# the source code and build that before checking | |
$tarext = ".tar.gz" | |
$wildcard = "_*.9*$tarext" | |
$pattern = $pkgname + $wildcard | |
$emptystr = "" | |
$archs = Get-ChildItem -Filter $pattern | | |
ForEach-Object { | |
($_.Name).Replace($tarext, $emptystr) | |
} | | |
Sort-Object -Descending | |
$pkgname = $archs[0] + $tarext | |
$opts = "--as-cran" | |
} | |
& "Rcmd.exe" $Command $opts $pkgname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment